-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ex24_GuessGame3.py
39 lines (37 loc) · 1.26 KB
/
Ex24_GuessGame3.py
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
# Check out my Youtube channel:
# https://www.youtube.com/channel/UCRYxPJle46XMws4ewJE-ShQ
c_guess = 50
widedict = {}
lowest = 0
highest = 100
guess_counter = 0
while True:
uin = input(f"my guess is {c_guess}, what's your opinion about? \n(VeryHigh(vh), High(h), True(t), Low(l), VeryLow(vl)\n> ").lower()
if uin == 't':
print('u are right!')
break
elif uin == 'vh' and c_guess not in widedict:
widedict.update({c_guess: uin})
highest = c_guess
c_guess = (c_guess+lowest)//2
elif uin == 'h' and c_guess not in widedict:
widedict.update({c_guess: uin})
highest = c_guess
c_guess -= 2
elif uin == 'l' and c_guess not in widedict:
widedict.update({c_guess: uin})
lowest = c_guess
c_guess += 2
elif uin == 'vl' and c_guess not in widedict:
widedict.update({c_guess: uin})
lowest = c_guess
c_guess = (c_guess+highest)//2
while c_guess in widedict and widedict[c_guess] == 'h':
widedict.update({c_guess: uin})
c_guess -= 1
while c_guess in widedict and widedict[c_guess] == 'l':
widedict.update({c_guess: uin})
c_guess += 1
guess_counter += 1
print(f"you've made {guess_counter} times guess")
print(widedict)