-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessgame.py
More file actions
25 lines (22 loc) · 751 Bytes
/
guessgame.py
File metadata and controls
25 lines (22 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import random
winning_no = random.choice(1,100)
# winning_no= 55
guess= 1
guessed_no= int(input("enter any no"))
game_over= False
while not game_over:
# while True:
# while True: can run infinite loop
# guessed_no= int(input("enter any no"))
if guessed_no == winning_no:
print(f"you win, your times to win{guess}")
# break
game_over= True # can use break
else:
if guessed_no < winning_no:
print("too low") # guess += 1 # guessed_no= int(input("guess again")) #not use 2 times
else:
print("too high")
guess += 1
# continue
guessed_no= int(input("guess again")) # we can use continue if gueesed no statement in loop