Comparing strings in Python

0 votes
How can I compare two strings in python regardless of their casing? Like, "Match" and "match" are actually the same words but one is capitalized. Please tell me how to ignore the casing during string comparsion.
May 28, 2018 in Python by newbie
16 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Convert both the strings to either uppercase or lowercase and then perform the comparison.

if string1.lower() == string2.lower():
     #compare
answered May 28, 2018 by Nietzsche's daemon
• 4,260 points

Related Questions In Python

0 votes
1 answer

comparing strings in Python using "==" or "is"

is is used for identity testing and ...READ MORE

answered Sep 19, 2018 in Python by SDeb
• 9,740 points
22 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 56,120 points
19 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

answered Sep 20, 2018 in Python by Priyaj
• 56,120 points
32 views
0 votes
1 answer

Comparing two files contents in python

This code should work for you: It ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 56,120 points
20 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
27 views
+4 votes
6 answers
0 votes
1 answer

Reversing strings in Python

The fastest way to reverse string is ...READ MORE

answered May 7, 2018 in Python by Nietzsche's daemon
• 4,260 points
15 views
0 votes
1 answer

Sorting a list of strings in Python

Use the sort function mylist.sort() READ MORE

answered May 29, 2018 in Python by Nietzsche's daemon
• 4,260 points
14 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.