I want to make if comparisons not care about the capitals.
I have tried to Google this but nothing shows up with the answer im looking for.
Example Code:
word = input()
if word == 'banana':
print("Apples")
I want to make if comparisons not care about the capitals.
I have tried to Google this but nothing shows up with the answer im looking for.
Example Code:
word = input()
if word == 'banana':
print("Apples")
Can do:
word = input()
if word.lower() == 'banana':
print("Apples")
Also recommend: How do I do a case-insensitive string comparison?
Use the built-in lower()
function like this:
word = input()
if word.lower() == 'banana':
print("Apples")
You could transform input
to lowercase like this:
word = input()
if word.lower() == 'banana':
print("Apples")