maynul67

Bull and Cow Game

Jul 20th, 2021
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. user =input("enter a 4 digit number :")
  2. import random
  3.  
  4. comp = str(random.randint(1000,9999))
  5.  
  6. i = 0
  7. bull = 0
  8. cow = 0
  9. while i<4:
  10.     if user[i] == comp[i]:
  11.         bull = bull + 1
  12.     i += 1
  13.    
  14. e = 0  
  15. while e<4:
  16.         if user[e] in comp:
  17.             cow = cow + 1
  18.         e = e + 1
  19. print(comp)
  20. print(bull)
  21. print(cow)
Advertisement
Add Comment
Please, Sign In to add comment