vendredi 27 mars 2020

Evaluation of If Statement - Python

I'm sorry if this post has been answered or is a stupid question. I have searched quite a bit to no avail. I'm not new to Python or coding but have been working on the same project all day, so may have a little fatigue included in this question. Anyways, in my code, recovered_list[11] is equal to a string value of "-". However, when I try and evaluate using the following if statement, it's always false.

I have tried replacing == with is, I have tried evaluating "-" with single quotes. Neither working. I feel like I am being stupid and missing something simple, but alas I am frustrated and asking here anyway. Thanks for your help.

print(recovered_list[11])
if recovered_list[11] == "-":
    print("true")
else:
    print("false")

Aucun commentaire:

Enregistrer un commentaire