vendredi 11 mai 2018

Executing code only if two previous conditions are not matched

hey i don't know how to programm this constellation :

string = " "
if "abc" in string:
    print ("abc is in string")
if "def" in string:
    print ("def is in string")
else:
    print ("abc and def are not contained in string")

It should go to "else" only if the 2 conditions aren't true. But if both substrings are contained in string; it should print both.

Aucun commentaire:

Enregistrer un commentaire