dimanche 15 mars 2020

why is this script repeating itself?

i'm trying to teach myself python, i recently learned how to use raw input in an if statement (yes or no). however, when I anwser yes, the program asks me the same if question. can anyone help? i'm not really good at programming but love doing it.

import time
name = raw_input("what is your name? ")
print "Hello " + name
#yes no statement with raw input
while True:
        yesno = raw_input("would you like to play hangman?")
        if yesno.lower().startswith("n"):
                print("ok bye")
                exit()
        elif yesno.lower().startswith("y"):
                print("cool, let me prep for e second")
                time.sleep(5)
# this is where it goes wrong
# below is what is supposed to follow
word = "kaasblok"
guesses = ''
turns = 6
while turns > 0:

Aucun commentaire:

Enregistrer un commentaire