Looking at your full code, you have the following:
if AMPM == "Am" or AMPM == "am":
AMPM = "AM"
if AMPM == "Pm" or AMPM == "pm":
AMPM = "PM"
if AMPM is not "AM" or AMPM is not "PM":
AMPM = input('You entered an incorrect value for AMPM. Please, try again: ')
You already checked everything you need above! The part you asked about is what you want to perform when all else fails. This is what the else
clause is for. So you can fix the code (and make it more clean and readable) like this:
if AMPM == "Am" or AMPM == "am":
AMPM = "AM"
elif AMPM == "Pm" or AMPM == "pm":
AMPM = "PM"
else:
AMPM = input('You entered an incorrect value for AMPM. Please, try again: ')
In case this is new - elif
means 'else-if'. If the first if
is evaluated to false, the program checks the next elif
after it. If all clauses are false, the else
section is executed.