K1ngkai

Untitled

Mar 7th, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. run = True
  2. second_chance = True
  3.  
  4. def main():
  5. global attempt
  6. print('What is the lowest number of attempts do you think it will take you to guess my number between 1-100?')
  7. print('Lets give it a try?')
  8. print()
  9. game()
  10. attempts()
  11. prev_score = []
  12.  
  13.  
  14. def game():
  15. import random
  16. attempt = 0
  17. prev_score = 0
  18. comp_number = random.randint(1, 100)
  19. while run:
  20. player_number = int(input('Enter number: '))
  21. if player_number == comp_number:
  22. print(f'Wow that was my number! You did it in {attempt} attempts!')
  23. attempt += 1
  24. break
  25. elif player_number < comp_number:
  26. attempt += 1
  27. print('Your number is too low, try again.')
  28. elif player_number > comp_number:
  29. attempt += 1
  30. print('Your number is too high, try again.')
  31.  
  32. if prev_score < attempt:
  33. print('Your last attempt was better, keep trying and maybe you will get better :P')
  34. elif prev_score > attempt:
  35. print('Nice job! You beat your previous score!')
  36. elif prev_score == attempt:
  37. print('Well you tied your previous score. Keep trying!')
  38. print()
  39. another_game()
  40.  
  41.  
  42. def another_game():
  43. while second_chance:
  44. print('Would you like to try and lower your score?')
  45. play_again = input("Type 'yes' to continue, or 'no' to give up: ")
  46. if play_again == 'no' or 'No':
  47. print('Are you sure you want to give up?')
  48.  
  49. give_up = input("Type 'yes' to quit: ")
  50. if give_up == 'yes' or 'Yes':
  51. exit()
  52. else:
  53. return main()
  54.  
  55. sec_chance()
  56. print()
  57.  
  58.  
  59.  
  60. main()
Advertisement
Add Comment
Please, Sign In to add comment