0

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")
zabop
  • 5,493
  • 3
  • 23
  • 56
CM3K
  • 1
  • 1
  • 1

3 Answers3

0

Can do:

word = input()
if word.lower() == 'banana':
    print("Apples")

Also recommend: How do I do a case-insensitive string comparison?

zabop
  • 5,493
  • 3
  • 23
  • 56
0

Use the built-in lower() function like this:

word = input()
if word.lower() == 'banana':
    print("Apples")
Tom Gebel
  • 643
  • 1
  • 2
  • 11
0

You could transform input to lowercase like this:

word = input()
if word.lower() == 'banana':
    print("Apples")
willcrack
  • 1,603
  • 8
  • 18
Matheus Delazeri
  • 338
  • 1
  • 11