Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- # constants
- FIVE_MINUTE = 5 * 60 # second
- FIVE_SECOND = 5 # second
- # TIME_BUFFER = FIVE_MINUTE
- TIME_BUFFER = FIVE_SECOND
- # pake 5 detik aja buat ngetestnya biar gampang.
- # kalo mau 5 menit, ganti jadi TIME_BUFFER = FIVE_MINUTE
- # states
- user = {"name": "Nama User", "password": "test123" }
- session = {"iterationCount": 0, "lastEntryTime": 0 }
- def main():
- while(True):
- password = raw_input('masukan password: ')
- # check kalo udah boleh nyoba password baru atau belom
- if(session["lastEntryTime"] + TIME_BUFFER > time.time()):
- print("anda belum boleh mencoba lagi sampai")
- elif(password == user["password"]):
- print('password sudah benar')
- print("program selesai")
- break
- else:
- print("password salah")
- session["lastEntryTime"] = time.time()
- session["iterationCount"] = session["iterationCount"] + 1 # ngga penting sih.
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement