vendredi 27 octobre 2017

Python repeat until a no is given? [duplicate]

This question already has an answer here:

I have this code and it works, but I want to ask the user if they want to search again and then repeat the if statement until they say no and then close it out.

f = open("daily.txt","r")
print "What name? "

while True:
    s = raw_input('>  ')
    if s in f.read():
        print "name is listed"
        break
    else: 
        print 'name is not listed'
        break


f.close()
print('n\)

raw_input("Press enter to continue....")

Aucun commentaire:

Enregistrer un commentaire