-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guess The Number.py
42 lines (31 loc) · 941 Bytes
/
Guess The Number.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import random
print("""
Guess The Number!!!
---------------------
Pick a Number Between 1-100
You Get 3 Tries!
Good Luck!
""")
answer = random.randint(1, 100)
lives = 5
def main():
global answer, lives
while True:
if lives == 5:
player_answer = int(input("Enter Your Answer: "))
elif lives == 4 or lives == 3 or lives == 2 or lives == 1:
player_answer = int(input("Try Again: "))
if lives != 0:
if player_answer > answer:
print("Too High! \n")
lives -= 1
if player_answer < answer:
print("Too Low! \n")
lives -= 1
if player_answer == answer:
print("You Win GGEZ! \n")
if lives == 0:
break
if __name__ == "__main__":
main()
print("You Lose!")