Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import sys
  2.  
  3. def tarkistus(merkkijono):
  4. if len(merkkijono) != 4:
  5. print "Use 4 symbols!"
  6. return False
  7.  
  8. else:
  9. for i in range(4):
  10. if merkkijono[i] not in "123456":
  11. print "Invalid symbol! Use numbers between 1-6!"
  12. return False
  13. return True
  14.  
  15. if len(sys.argv) == 1:
  16. print "Give secret code"
  17. sys.exit()
  18.  
  19.  
  20. koodi = sys.argv[1]
  21.  
  22.  
  23. if tarkistus(koodi) == True:
  24. while True:
  25. arvaus = raw_input("Give guess: ")
  26.  
  27. if arvaus == koodi:
  28. print "You win!"
  29. print "the correct answer was", koodi
  30. break
  31.  
  32. elif tarkistus(arvaus) == True:
  33.  
  34. for i in range(4):
  35. if koodi[i] == arvaus[i]:
  36. print "Symbol in correct position"
  37. elif arvaus[i] in koodi:
  38. print "Correct symbol"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement