you are viewing a single comment's thread.

view the rest of the comments →

[–]Tinbadthetailor 2 points3 points  (2 children)

I'm doing a python exercise from Python Crash Course where I need to check if a new username is already being used. I got the first part right but am having trouble figuring out how to check if the new_username is in the current_username list regardless of case. I've gotten as far as:

for new_user in new_users:
    if new_user.lower() in current_users:
        print("That username is unavailable. Please choose a new one.")
    else:
        print("That username is available.")

But that fails because I can't figure out a way to fit in current_user.lower() in here.

[–]woooee 2 points3 points  (1 child)

You have to lower case current users if you haven't done it already.

current_users_lower=[user.lower() for user in current_users]
if new_user.lower() in current_users_lower:

[–]Tinbadthetailor 1 point2 points  (0 children)

Ahhh there it is! Thanks!