I am relatively new at programming and working through LPTHW. I want to build a function that will check if a raw_input() is a number and and then return either float(input) or simply the original input if not a number.
I have determined that input.isdigit() is an acceptable function to use, but now I am struggling building the function that will actually return the variable after the if statement compiles. I believe using the global function will help me, but after reading some posts, it doesn't sound like global is very "effective" tool.
This is what I have thus far.
def Number_Check(input):
global input
if input.isdigit():
input = float(input)
else:
input = input
Running this in the shell gives me the error:
SyntaxError: name 'input' is local and global (ex36.py, line 19)
Any help on this is greatly appreciated.
def Number_Check(input)todef Number_Check(), or if it is a different variable, just rename it.