Advertisement
mbstanchev

Игра на числа

May 21st, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import random
  2. print("Let's play the game - Guess the number from 1 to 100\nYou have 10 tries")
  3.  
  4. list1 = list(range(1,101))
  5. counter_of_sugestions = 0
  6. sugestions = []
  7. current_num = random.choice(list1)
  8. for i in range(10):
  9.  
  10. sugestion = input("Enter your sugestion: ")
  11. current_num = int(current_num)
  12. sugestion = int(sugestion)
  13.  
  14. sugestions.append(sugestion)
  15.  
  16. #print("You'v tride that on")
  17.  
  18.  
  19. if sugestion != current_num:
  20. print("Wrong")
  21.  
  22. if sugestion < current_num:
  23. print("the num is higher!\n")
  24. counter_of_sugestions +=1
  25. elif sugestion > current_num:
  26. print("The num is lower!\n")
  27. counter_of_sugestions += 1
  28. else:
  29. print(f"congratilations you guest the number {current_num}")
  30. print(f"you guest the num in {counter_of_sugestions} tries")
  31. break
  32. else:
  33. print(f"Good luck next time \nThe number is {current_num}")
  34.  
  35.  
  36.  
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement