Your expressions return false so number is not defined. add
number = " string is not equal to a number."
before the expression.
I think your trying to get a number value for each character? you should be comparing if the value of alphabet equals a given string, then assigning a numerical value to number.
I.E.
if alphabet.upper() == "A": number=1
3
solved Hi. Why am I getting “NameError: name ‘number’ is not defined ” for this code? Please help me here as I have no idea [closed]