Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
incomplete registration
#4
(May-12-2017, 04:00 PM)nilamo Wrote:
(May-12-2017, 03:43 PM)Low_Ki_ Wrote:
    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
Why is that a for loop, if you always return in the first iteration?  Or is it an error that you currently only check the first username?

You're right. I should use the
if any()
just like the above check... Thanks for noticing that!

I wrote this... still not working correctly... could I get some help with this block?

if any(k.lower() in existing_usernames.keys() for k in username[0].lower()):
        print('Username taken')
        return None
    else:
        print('Username available')
        return username

if any(k in existing_usernames.keys() for k in username):
        print('Username taken')
        return None
    else:
        print('Username available')
        return username
works... but where would I add the .lower() function to check username properly?
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 424 May-14-2024, 07:46 AM
Last Post: gavin34
  Incomplete Output oldcity 6 3,776 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