Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
incomplete registration
#2
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_username
to:

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
Reply


Messages In This Thread
incomplete registration - by Low_Ki_ - May-12-2017, 12:08 AM
RE: incomplete registration - by Low_Ki_ - May-12-2017, 03:43 PM
RE: incomplete registration - by nilamo - May-12-2017, 04:00 PM
RE: incomplete registration - by Low_Ki_ - May-12-2017, 04:12 PM
RE: incomplete registration - by nilamo - May-12-2017, 04:57 PM
RE: incomplete registration - by Low_Ki_ - May-12-2017, 05:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keep getting "SyntaxError: incomplete input" but can't see why. Pedroski55 3 583 May-14-2024, 07:46 AM
Last Post: gavin34
  Incomplete Output oldcity 6 3,842 Oct-21-2018, 07:08 PM
Last Post: oldcity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020