system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
vivid |
Hello,
is there a function to compare 2 string ?
I’m from ‘C’ and I’m lost
Thank you.
if test[1] in “moi” :
print(“ok”)
???
system
2
|
|
|
|
Reply From: |
Zylann |
If by “compare” you mean check equality, you can just do string1 == string2
which gives you true
if the strings are equal.
If you need a comparison usable for alphabetic sorting, you can also do string1 < string2
, which returns true
if string1
comes before string2
.