samedi 11 août 2018

Python if condition not working as anticipated

I have the following code:

word = ""
if (letter=="a" for letter in word):
    print("a found!")

which prints a found! even though word variable is empty. Why is this happening? And what is the right way to do what I want?

Aucun commentaire:

Enregistrer un commentaire