i'm trying to figure out how the and operator works. and in my small example it does not what i expected.
i'm afraid this could be a newbie mistake, sorry.
i provide a string variable.
i check with if and and if there are two elements in the string.
if yes i change the string.
in my example the string is changed even if the two elements are NOT in the string.
name = "ABCD EFGH"
if "ZZ" and "EFGH" in name:
name = "ZZZZ"
else:
pass
print(name)
i'd expect the output to be ABCD EFGH, since ZZ is not in the string.
and when using AND both, ZZ and EFGH should be in the string.
but the actual output is ZZZZ.
Aucun commentaire:
Enregistrer un commentaire