0

Where to put: number of all guesses in guess game, PY ?

My code is: print("Guess the number. Try:") number = random.randint(1, 10) while True: a = int(input("number")) if a == number: print(" You are right!, the number is ", number) break else: print("Try again") I want to put number of guesses after print(" You are right!, the number is ", number)

30th Sep 2020, 3:21 PM
Martyna Tomaszewska
Martyna Tomaszewska - avatar
2 Antworten
+ 2
Declare variable at the beginning that will hold tries amount and add its incrementation in else block 😉 edit. that incrementation should be right before "if" instead of in else block 😅
30th Sep 2020, 3:24 PM
ThreeG
ThreeG - avatar
0
Great thx :)
30th Sep 2020, 5:00 PM
Martyna Tomaszewska
Martyna Tomaszewska - avatar