Erick = input ("Kobia, what's ur favourite team ?")
print (" ")
if Erick.upper() == "manchester city":
print ('All hail Pep.')
print ('Heri nyinyi kuliko Man united,')
print ('Liverpool have been awful this season.')
else:
print ('Arsenal gladly sit on top of the table.')
print (" ")
When I input manchester city, the code only prints out the 'else' part of the function
Whatever I type in, the code prints out the 'else' part of the function
what might the problem be ?
CodePudding user response:
Try this code where I have only add .upper()
to the string 'manchester city'
:
Erick = input("Kobia, what's ur favourite team ?")
print(" ")
if Erick.upper() == "manchester city".upper():
print('All hail Pep.')
print('Heri nyinyi kuliko Man united,')
print('Liverpool have been awful this season.')
else:
print('Arsenal gladly sit on top of the table.')
print(" ")
You can input 'manchester city'
, 'Manchester City'
, and so on and all inputs are OK for the if
condition.
CodePudding user response:
Change condition Erick.upper() == "manchester city"
to Erick.lower() == "manchester city"
Because with your code you are comparing MANCHESTER CITY
with manchester city