Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- guess_counter = 0
- def ranger(ch, gue, lis):
- while ch.lower() != 'h' and ch.lower() != 'l':
- print("Wrong input!!")
- ch = input("Was it higher or lower? H | L\n")
- if ch.lower() == 'h':
- lis = [c for c in range(gue + 1, lis[-1] + 1)]
- if ch.lower() == 'l':
- lis = [c for c in range(lis[0], gue)]
- return lis
- print("Welcome to \"Guess the Number 2.0\"\nthis time you'll select a number and I'll try to guess it")
- guess = random.randint(0, 100)
- number_list = [c for c in range(0, 101)]
- choicer = ''
- while choicer.lower() != 'y':
- print("My guess is:", guess)
- guess_counter += 1
- choicer = input("Was my guess right? Y | N\n")
- while choicer.lower() != 'y' and choicer.lower() != 'n':
- print("Wrong input!!")
- choicer = input("Was my guess right? Y | N")
- if choicer.lower() == 'y':
- print("Nice!\n number of guesses:", guess_counter)
- if choicer.lower() == 'n':
- number_locator = input("Was it higher or lower? H | L\n")
- number_list = ranger(number_locator, guess, number_list)
- print(number_list)
- guess = random.choice(number_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement