Help me


Joined
Aug 2, 2022
Messages
2
Reaction score
0
Code:
current_users = [ 'Red' , 'Mike' , 'Mery', 'Fred']
new_users = [ 'red', 'gyu' , 'gje', 'fred']

for new_user in new_users :
if new_user in current_users :
print(" nick not available")
else :
print(" nickname available")

My problem:

How to make Python ignore uppercase and lowercase letters. For example, the site already has a nickname "Red",then "RED" is also unavailable. (For this, you need to make a copy of "current _users" which will contain all elements "current_users" but written in small letters.

Thanks
 
Ad

Advertisements

Joined
May 11, 2022
Messages
47
Reaction score
3
you can use the upper function.
Python:
current_users = [ 'Red' , 'Mike' , 'Mery', 'Fred']
new_users = [ 'red', 'gyu' , 'gje', 'fred']


for i in range(0,len(current_users)):
   check = False
   for j in range(0,len(new_users)):
      if current_users[i].upper() ==new_users[j].upper():
         check = True
   if check:
      print("nick not available")
   else:
      print("nickname available")
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top