K1ngkai

Untitled

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