“So wiederholen Sie die IF -Aussage in Python” Code-Antworten

So wiederholen Sie die IF -Aussage in Python

def main():
    while True:
        again = raw_input("Would you like to play again? Enter y/n: ")

        if again == "n":
            print ("Thanks for Playing!")
            return
        elif again == "y":
            print ("Lets play again..")
        else:
            print ("You should enter either \"y\" or \"n\".")

if __name__ == "__main__":
    main()
Distinct Duck

So wiederholen Sie die IF -Aussage in Python

while score <= 3:
    again =raw_input("Whould you like to play again? Enter y/n: ")
    
  if again == "n":
    print ("Thanks for playing!")
    
  elif again == "y":
    print("Lets play again..")
  else:
    print("You should enter either \"y\" or \"n\'.")
senula sethunga

So wiederholen Sie die IF -Aussage in Python

# based off Distinct Duck's answer but with a slightly different syntax to look more "realistic"

while True:
	again = raw_input("Would you like to play again? Enter y/n: ")
    
    if again == 'n':
    	print("Thanks for Playing!")
        break # Now that's more like it.
    elif again == 'y':
    	print("Let's play again..")
    else:
    	print("You should enter either \"y\" or \"n\".")
Nicholas Marques Linhares De Moraes

Ähnliche Antworten wie “So wiederholen Sie die IF -Aussage in Python”

Fragen ähnlich wie “So wiederholen Sie die IF -Aussage in Python”

Weitere verwandte Antworten zu “So wiederholen Sie die IF -Aussage in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen