samedi 29 avril 2017

Python for loop ignoring if statement

For some reason python is ignoring my if statement, even if the str(search) is in lista it still prints the elif statement regardless, am i doing something wrong?

    search = input("what would you like to search for?:")
    for n in range(len(lista)):
         if str(search) in lista[n]:
             print(lista[n])
         elif str(search) not in lista[n]:
             print("search not found in list")
             break 

Aucun commentaire:

Enregistrer un commentaire