[SOLVED] Why doesn't input return a the print value with .lower() or .upper() commands?

Issue

When i run the code my python doesn’t recognize what i put in whether it’s with .lower or .upper, why is that?

import sys

Good = input('Am i Good? > ').upper()
if Good == 'no':
print(True, 'You are good')
elif Good == 'no':
print(True, ' You are still good')
elif Good == 'quit':
sys.exit()

Solution

In this line of code:

Good = input('Am i Good? > ').upper()

You transform the input to uppercase, but then you compare the string with lowercase strings ("no", "quit"). This will never match since "NO" and "no" are different strings (Python cares about case when comparing strings).

Answered By – aaossa

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *