-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurprise_message.py
More file actions
33 lines (28 loc) · 931 Bytes
/
surprise_message.py
File metadata and controls
33 lines (28 loc) · 931 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
25
26
27
28
29
30
31
32
33
from random import randint
def guess_a_number():
scores = 0
message = "em ot tol a naem uoY"
try:
name = input("Hello there! Tell us your name:")
except ValueError:
print("Please enter your name:")
numbers = randint(1, 10)
for _ in range(5):
try:
user = int(input("Guess a number(1-10):"))
except ValueError:
print("Please enter a number(1-7)")
if user == numbers:
print("You guessed the number correctly!")
scores += 10
else:
print("Your guess was wrong.")
scores -= 1
print("|||||||||||||||||||||||||||||||||||||||||||||||||||||")
print(f"Your total score is {scores}")
if scores >= 1:
print("Congratulations! You've unlocked a surprise message.")
print(f"{name}",message)
else:
print("Better luck next time.")
guess_a_number()