Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import random
  2.  
  3. guess_counter = 0
  4.  
  5.  
  6. def ranger(ch, gue, lis):
  7. while ch.lower() != 'h' and ch.lower() != 'l':
  8. print("Wrong input!!")
  9. ch = input("Was it higher or lower? H | L\n")
  10.  
  11. if ch.lower() == 'h':
  12. lis = [c for c in range(gue + 1, lis[-1] + 1)]
  13.  
  14. if ch.lower() == 'l':
  15. lis = [c for c in range(lis[0], gue)]
  16. return lis
  17.  
  18.  
  19. print("Welcome to \"Guess the Number 2.0\"\nthis time you'll select a number and I'll try to guess it")
  20. guess = random.randint(0, 100)
  21. number_list = [c for c in range(0, 101)]
  22. choicer = ''
  23.  
  24. while choicer.lower() != 'y':
  25. print("My guess is:", guess)
  26. guess_counter += 1
  27. choicer = input("Was my guess right? Y | N\n")
  28.  
  29. while choicer.lower() != 'y' and choicer.lower() != 'n':
  30. print("Wrong input!!")
  31. choicer = input("Was my guess right? Y | N")
  32.  
  33. if choicer.lower() == 'y':
  34. print("Nice!\n number of guesses:", guess_counter)
  35. if choicer.lower() == 'n':
  36. number_locator = input("Was it higher or lower? H | L\n")
  37. number_list = ranger(number_locator, guess, number_list)
  38. print(number_list)
  39. guess = random.choice(number_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement