-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (26 loc) · 826 Bytes
/
main.py
File metadata and controls
35 lines (26 loc) · 826 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
34
35
import random
def guess(x):
random_number = random.randint(1, x)
guess = 0
while guess != random_number:
guess = int(input(f"Input number between 1 and {x} : "))
if guess > random_number:
print("Number is smaller")
elif guess < random_number:
print("Number is bigger")
print("Correct !")
def guess_computer(x):
high = x
low = 1
feedback = ''
while feedback != 'c':
guess = random.randint(low, high)
feedback = input(f"Is {guess} correct(c)?? or too high (h) , or too low(l)?? ").lower()
print(feedback)
if feedback == "h":
high = guess - 1
elif feedback == "l":
low = guess + 1
print(low)
print(f"Yay computer guessed {guess} correctly")
guess_computer(100)