Nov-29-2020, 05:55 PM
I have a list of current users in list.
I have a list of new users in a list.
I want to loop through the new users and make sure the username has not been used already. If it has print a bespoke message.
This works fine as below:
BUT the problem is that usernames can be in any case.
Is there a way straightforward way in Python I can check equality regardless of the case?
Thanks in advance.
I have a list of new users in a list.
I want to loop through the new users and make sure the username has not been used already. If it has print a bespoke message.
This works fine as below:
1 2 3 4 5 6 7 8 9 |
current_users = [ 'user1' , 'user2' , 'user3' , 'user4' , 'user5' ] new_users = [ 'user1' , 'user11' , 'user12' , 'user13' ] for user in new_users: if user in current_users: print ( "Username already used" ) else : print ( "OK go ahead" ) |
Is there a way straightforward way in Python I can check equality regardless of the case?
Thanks in advance.