vendredi 5 avril 2019

Compare string to multiple strings in Python3

I want to know if there is no text string in the variables. And then compare if there is another text string. The variables results It may contain the following: yes, no or ? I have follow code:

internet = result1
vpn = result2
zetas = result3

values = [internet, vpn, zetas]

    if any(v !== "?" for v in values):
        print("No exist ?")
    if any(v == "no" for v in values):
        print("Exist a NO")
    else:
        print("Good")

especially to see the most elegant way of doing this.

Aucun commentaire:

Enregistrer un commentaire