2022-10-14 22:03:25 +00:00
|
|
|
# Complete the code to make the HiLo game...
|
|
|
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# Pick a random number between 1 and 100, inclusive
|
|
|
|
secret = random.randrange(1, 101)
|
|
|
|
print("Can you guess my secret?")
|
|
|
|
# put your code here
|
|
|
|
c = 0
|
2022-10-18 17:18:56 +00:00
|
|
|
trieslist = []
|
2022-10-14 22:03:25 +00:00
|
|
|
num = -1
|
|
|
|
while secret != num:
|
|
|
|
num = int(input('>>> '))
|
|
|
|
if num > secret:
|
|
|
|
print('High')
|
|
|
|
if num < secret:
|
|
|
|
print('Low')
|
|
|
|
c += 1
|
2022-10-18 17:18:56 +00:00
|
|
|
trieslist.append(str(num))
|
|
|
|
triesstr = ', '.join(trieslist)
|
2023-05-16 20:14:36 +00:00
|
|
|
print(f'Well done! The secret number was {secret}. It took you {c} tries to get it right.\nList of tries: {triesstr}')
|
2022-10-14 22:03:25 +00:00
|
|
|
|
2022-10-18 17:18:56 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|