Advertisement
mbstanchev

Igrichka

May 22nd, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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. suggestions = []
  7. current_num = random.choice(list1)
  8. for i in range(10):
  9.  
  10. sugestion = input("Enter your sugestion: ")
  11.  
  12. current_num = int(current_num)
  13. sugestion = int(sugestion)
  14.  
  15. if sugestion in suggestions:
  16. print("You'v tride that one!!\n")
  17. continue
  18. suggestions.append(sugestion)
  19.  
  20. if sugestion != current_num:
  21. print("Wrong")
  22.  
  23. if sugestion < current_num:
  24. print("the num is higher!\n")
  25. counter_of_sugestions +=1
  26. elif sugestion > current_num:
  27. print("The num is lower!\n")
  28. counter_of_sugestions += 1
  29. else:
  30. print(f"congratilations you guest the number {current_num}")
  31. print(f"you guest the num in {counter_of_sugestions} tries")
  32. break
  33.  
  34. else:
  35. print(f"Good luck next time \nThe number is {current_num}")
  36.  
  37.  
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement