-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguess number
48 lines (35 loc) · 1.2 KB
/
guess number
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
#Number Guessing Game Objectives:
# Include an ASCII art logo.
# Allow the player to submit a guess for a number between 1 and 100.
# Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer.
# If they got the answer correct, show the actual answer to the player.
# Track the number of turns remaining.
# If they run out of turns, provide feedback to the player.
# Include two different difficulty levels (e.g., 10 guesses in easy mode, only 5 guesses in hard mode).
from art import logo
import random
print(logo)
print("WWelcome to number guessing game")
print("Tyype number between 1 and 100")
ran = []
ran = range(1,100)
number = random.choice(ran)
print(f"psst, the number is {number}")
diff = input("Choose difficuly easy or difficult: ")
if diff == 'easy':
diff_n = 5
else:
diff_n = 10
print(f" you have {diff_n} attempts")
for i in range(1,diff_n+1):
guessed = int(input("Make a guess "))
if guessed > number:
print("too high")
elif guessed < number:
print("too low")
elif guessed == number:
print("guessed it correct")
break
if (diff_n-i) != 0:
print("guess again")
print(f"you have {diff_n - i} remaining")