# File: tuThPins.py # Author: Dr. Gibson # Date: 11/15/2016 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that creates and stores # randomly-generated pins for users. import random MIN_PIN = 0 MAX_PIN = 9999 QUIT = "quit" def main(): # explicitly seed it with the system time random.seed() # this does the same thing as logins = {} logins = dict() name = input("Please enter your username ('quit' to quit): ") # this is terrible, never do this while name != QUIT: # this means the name already exists #if logins.get(name) != None: if name in logins: print("The pin for", name, "is", logins[name]) else: # generate a random pin for them newPin = random.randrange(MIN_PIN, MAX_PIN + 1, 1) logins[name] = newPin print("The pin for the new user", name, "is", logins[name]) # ask for another username name = input("Please enter your username ('quit' to quit): ") print(logins) main()