mercredi 28 janvier 2015

Why doesn't if, elif or else work with .lower() in Python? [on hold]

The program needs to accept and match any upper and lower case versions of the word, which is why .lower() is used. When this is ran and 'January' is entered, the else line is printed instead of the if line.



month = input("\nPlease enter the month\n")
if month.lower == ("january"):
month = int(1)
print(month)
elif month.lower == ("february"):
month = int(2)
print(month)
elif month.lower == ("march"):
month = int(3)
print(month) #etc.
else:
print("That is not a month\n")

Aucun commentaire:

Enregistrer un commentaire