Advertisement
dlee427

If exercise #1

Feb 5th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. >>> def mar():
  2.     pw = 'a'
  3.    
  4.     count = 3
  5.     currentcount = 0
  6.     while currentcount < count:
  7.         upw = input('Enter password: ')
  8.         if pw == upw:
  9.             print('correct')
  10.             currentcount = count
  11.             exit()
  12.         else:
  13.             print('sorry')
  14.             currentcount = currentcount +1
  15.             if currentcount == 3:
  16.                 print('youve been denied')
  17.                 exit()
  18.  
  19.            
  20. >>> mar()
  21. Enter password: a
  22. correct
  23. Traceback (most recent call last):
  24.   File "<pyshell#16>", line 1, in <module>
  25.     mar()
  26.   File "<pyshell#15>", line 11, in mar
  27.     exit()
  28.   File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site.py", line 362, in __call__
  29.     raise SystemExit(code)
  30. SystemExit: None
  31. >>> mar()
  32. Enter password: b
  33. sorry
  34. Enter password: b
  35. sorry
  36. Enter password: b
  37. sorry
  38. youve been denied
  39. Traceback (most recent call last):
  40.   File "<pyshell#17>", line 1, in <module>
  41.     mar()
  42.   File "<pyshell#15>", line 17, in mar
  43.     exit()
  44.   File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site.py", line 362, in __call__
  45.     raise SystemExit(code)
  46. SystemExit: None
  47. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement