-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (51 loc) · 1.57 KB
/
main.py
File metadata and controls
63 lines (51 loc) · 1.57 KB
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
53
54
55
56
57
58
59
60
61
62
63
from logo import logo
import random
import os
game_end = False
def easy_attempt(anser, attempt):
print(f"you have {attempt} guesses to guess the correct number")
user_guess = int(input("make a guess: "))
while attempt != 0:
if user_guess > anser:
print("Too High\nGuess Again")
attempt -= 1
easy_attempt(anser=anser,attempt=attempt)
elif user_guess < anser:
print("Too Low\nGuess Again")
attempt -= 1
easy_attempt(anser=anser,attempt=attempt)
elif user_guess == anser:
print("You win!")
os._exit(0)
print('You are out of guesses. You Lose! :(')
game_end = True
os._exit(0)
def hard_attempt(answer, attempt):
print(f"you have {attempt} guesses to guess the correct number")
user_guess = int(input("make a guess: "))
while attempt != 1:
if user_guess > answer:
print("Too High\nGuess Again")
attempt -= 1
easy_attempt(anser=answer,attempt=attempt)
elif user_guess < anser:
print("Too Low\nGuess Again")
attempt -= 1
easy_attempt(anser=answer,attempt=attempt)
elif user_guess == answer:
print("You win!")
os._exit(0)
print("You are out of gueeses. You Lose! :(")
game_end = True
os._exit(0)
while not game_end:
print(logo)
print("Welcome the number guesing game!")
display = print("Im thinking of a number between 1 and 100\n")
answer = random.randint(1, 100)
diffculty = input("choose your difficulty. Type 'easy' or 'hard': ").lower()
print(f"psst, the correct answer is {answer}")
if diffculty == 'easy':
easy_attempt(anser=answer, attempt=10)
elif diffculty == 'hard':
hard_attempt(answer=answer, attempt=5)