Untitled
unknown
python
a year ago
794 B
5
Indexable
import random
print("Welcome to the Number Guessing Game!")
print("I am thinking of a number between 1 and 100")
difficulty = input("Choose a difficulty. Type 'easy' or 'hard'")
if difficulty.lower() == "easy":
attempt = 10
elif difficulty.lower() == "hard":
attempt = 5
def guess(attempt):
strike = random.randint(1, 100)
print(strike)
while attempt:
print(f"You have {attempt} attempts remaining to guess the number")
num = int(input("Make a guess: "))
attempt -= 1
if num > strike:
print("Too High. Guess again")
elif num < strike:
print("Too Low. Guess again")
else:
print("Strike! You win the game")
return
guess(attempt)Editor is loading...
Leave a Comment