B
B
BaJar2018-03-13 23:14:51
Python
BaJar, 2018-03-13 23:14:51

How to do a case-insensitive comparison in Python?

It is necessary to compare 2 lines, while not taking into account the case in which they are written. The strings 'Hello' 'hello' 'HeLlO' 'hELLo' should compare as equal and output that the name is taken

current_users = ['Yaroslav', 'Misha', 'Grisha', 'Masha', 'Lilya']
new_users = ['Anna', 'Misha', 'Alex', 'Masha', 'Lilya']
for user in new_users:
    if user in current_users:
        print('Имя занято')
    else:
        print('Имя свободно')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aRegius, 2018-03-13
@BaJar

When comparing the drive and those to a single register.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question