input()
is always returned as a string and thus never equal to an integer.
The function then reads a line from input, converts it to a string (stripping a trailing newline)
See the documentation
Your if
or elif
is never true since an integer is not a string in the Python world (if you used an else
it would always return that) so you never define the new variable (since it is never run). What you need to do is to convert each input()
to an integer. This can be done using int()
function:
FlightLen=int(input("Would you like to book the '30' minutes flight or the '60'"))
Here FlightLen
has been converted to an integer once an input value has been given.
You do not need the ()
in the if
elif
statements if you are using Python 3 either:
if FlightLen==30:
elif FlightLen==60:
If you are using Python 2 print
does not take an ()
You might also want to add an else
to make sure FlightLen
is always defined, ensuring you do not get this error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…