“comment répéter si instruction en python” Réponses codées

comment répéter si instruction en 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

comment répéter si instruction en 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

comment répéter si instruction en 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

Réponses similaires à “comment répéter si instruction en python”

Questions similaires à “comment répéter si instruction en python”

Plus de réponses similaires à “comment répéter si instruction en python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code