May-12-2017, 03:43 PM
Fixed some repetitive stuff... IE:
def check_new_old(username, existing_usernames): new_username = username old_usernames = existing_usernames for k in old_usernames.keys(): if new_username[0].lower() == k.lower(): print('Username taken, prompting for new entry.') return None else: print('Username available.') return new_usernameto:
def check_new_old(username, existing_usernames): invalid_chars = '~ ` ! @ # $ % ^ & * ( ) + = { [ } ] : ; " \' < , > . ? / | \ '.split() if any(x in invalid_chars for x in list(username[0])) or (' ' in list(username[0])) or (len(username[0]) > 12): print('Username can\'t contain invalid characters and no longer than 12 characters: \n' + str(invalid_chars)) return None else: print('Need to fix check') pass for k in existing_usernames.keys(): if username[0].lower() == k.lower(): print('Username taken, prompting for new entry.') return None else: print('Username available.') return username