-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay-12
52 lines (50 loc) · 1.63 KB
/
Day-12
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
43
44
45
46
47
48
49
50
51
52
import random
from art import logo1
number = random.randint(1,100)
print("Welcome to the Number Guessing Game!")
print("I'm Thinking of number between 1 and 100.")
take = input("Choose a difficulty. Type 'easy' or 'hard': ")
def hard_level(number):
total = 5
print("You have 5 attempts remaining to guess the number.")
for _ in range(5):
check = int(input("Make a guess: "))
if check > number:
total -= 1
print("Too far.")
elif check < number:
total -= 1
print("Too low.")
else:
print(f"You got it! The answer was {number}")
exit()
if total > 0:
print("Guess again")
print(f"You have {total} attempts remaining to guess the number.")
else:
print("You have run out of guesses, you lose.")
print(f"The number was {number}")
def easy_level(number):
total = 10
print("You have 10 attempts remaining to guess the number.")
for _ in range(10):
check = int(input("Make a guess: "))
if check > number:
total -= 1
print("Too high.")
elif check < number:
total -= 1
print("Too low.")
else:
print(f"You got it! The answer was {number}")
exit()
if total > 0:
print("Guess again")
print(f"You have {total} attempts remaining to guess the number.")
else:
print("You have run out of guesses, you lose.")
print(f"The number was {number}")
if take == "easy":
easy_level(number)
elif take == "hard":
hard_level(number)