(May-12-2017, 04:00 PM)nilamo Wrote:(May-12-2017, 03:43 PM)Low_Ki_ Wrote: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?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
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 usernameworks... but where would I add the .lower() function to check username properly?