Please fix the problem


Kindly refer the images and the sentences below them.

*Image 1

If an integer/float is entered, then it shows its absolute value, which is normal.

*Image 2

If a “string” is entered, then it shows 'Not Applicable…". It is also normal.

*Image 3

If anything else is entered, then the desired ‘else’ command doesn’t work. Why? Another example in the below image.

*Image 4

Note: I am a beginner. This can be a stupid question. Kindly help.


Hi and 440o are undefined variable, but if you pass something valid which isn’t a string, integer or float else should work fine, for example a boolean:



What should I do so that if someone enters any other invalid character (like 440o or Hi or 123456 or @#45), a message displays to enter a valid character?


if someone enters another invalid character, what do you mean by this?

Things you code should be correct, otherwise you wise you get an error. If you use raw_input() to get user input (from the user using your program), then the input would be a string.

That is how it would normally be, you write a program, and then the clients use your program. But then the program must offer the functionality to get input from the user. So then there are no wrong values/undefined variable programmed into the code.

Then you must handle invalid user input, but this changes the program, given raw_input() will store the result as string. I think that is why this exercise is currently skipping doing the input step.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.