Guest User

Untitled

a guest
May 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import random
  2.  
  3. a = str(random.randint(1000,9999)) #3452
  4. print(a)
  5.  
  6. count = 1
  7.  
  8. def check_num():
  9. p = input("Enter input number: ")
  10. cows = bulls = 0
  11. for i in p:
  12. for j in a:
  13. if i==j:
  14. if a.find(i) == p.find(j):
  15. cows = cows+1
  16. else:
  17. bulls = bulls+1
  18. break
  19. else:
  20. continue
  21. print(cows, "cows", bulls, "bulls")
  22. return(cows)
  23.  
  24. while int(check_num()) != 4:
  25. count = count+1
  26.  
  27. print("Congratulations, you got the right number",a,"in",count,"tries.")
Add Comment
Please, Sign In to add comment