Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. import random
  3.  
  4. n = 0
  5. amount_right_played = 0
  6. amount_right_color = 0
  7.  
  8. code = [random.randint(0,5),random.randint(0,5),random.randint(0,5),random.randint(0,5)]
  9.  
  10. while n <12 and amount_right_played < 4:
  11. amount_right_played = 0
  12. amount_right_color = 0
  13.  
  14. number1 = int(raw_input('Eerste pion:? '))
  15. number2 = int(raw_input('Tweede pion:? '))
  16. number3 = int(raw_input('Derde pion:? '))
  17. number4 = int(raw_input('Vierde pion:? '))
  18.  
  19. guess = [number1, number2, number3, number4]
  20.  
  21. for i in range(4):
  22. if code[i]==guess[i]:
  23. amount_right_played = amount_right_played + 1
  24.  
  25. for i in range(4):
  26. if code[i] in guess and not(code[i]==guess[i]):
  27. amount_right_color = amount_right_color + 1
  28.  
  29. print code
  30. print guess
  31. print "Amount right color right place: %d" %(amount_right_played)
  32. print "Amount right color wrong place: %d" %(amount_right_color)
  33.  
  34. if amount_right_played < 4:
  35. print "Try again"
  36. else:
  37. print "WIN!!"
  38. n += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement