+ 1
Two questions:1, Strings is more similar with tuple ? 2, Why is false ?
1, Lists and strings are similar in many ways - strings can be thought of as lists of characters that can't be changed. 2, The in operator is also used to determine whether or not a string is a substring of another string. A=["spam",["eggs","sandwich"]] Print ("eggs" in A) -> false Print ("eggs" in A[1]) -> true Why???
3 Respostas
+ 2
Answer to your second question,
the list A has two elements "spam" and ["eggs","sandwich"] ,if u execute "eggs" in A it returns false because in is membership operator and A do not have any element "eggs" in it. **in compares the elemets as a whole **
+ 3
A string stores characters only (despite of encoding)
A tuple stores any type, including (among which) tuples, strings and other types.
+ 2
Thanks to you two guys