dimanche 25 avril 2021

Creating a loop of if statments

if explication == "y":
    print("The game is very simple, the programe generate a random number between 0 and 100 and your" +
    " objective is to guess it, if you type a number lower than the generated number i'll tell you" +
    " and the same will happen if you type a bigger number and there's a score if you guess wrong" +
    " it will decrease and when the score reach 0 you loose, that's all enjoy the game!")
if explication == "n":
    print("Great then we'll go straight to having fun!")

if explication != "n" and explication != "y":
    explication = input("please choose y or n: ")

So i started learning python and i wanted to do a simple fun program, and here i wanted to ask the user if he needed explication of the game that was simple to do, but i also wanted to make him choose another time if he miss clicked or he just wanted to type other things so i made the 3rd if statement, i also wanted it to repeat so if he keeps typing things other than y and n the program will always send "please choose y or n" until he he types either y or n is there a way to do this?

Aucun commentaire:

Enregistrer un commentaire