I was doing this ATM problem and got this error when I am running the test case.
Traceback (most recent call last):
** File “./prog.py”, line 1, in **
ValueError: could not convert string to float: '30 120.00’
Code:
x,y = float(input()).split(’ ')
if((x<1 or x>2000) or (y<0 or y>2000)):
quit()
#conditional for transaction
if(x%5==0):
if(x<y):
y = y - (x+0.5)
print(round(y,2))
else:
print(round(y,2))
else:
print(round(y,2))
Can anyone tell me where I am going wrong?
there is a mistake in split method …use this split(’ ')
x,y = float(input()).split(’ ')
if((x<1 or x>2000) or (y<0 or y>2000)):
quit()
#conditional for transaction
if(x%5==0):
if(x<y):
y = y - (x+0.5)
print(round(y,2))
else:
print(round(y,2))
else:
print(round(y,2))
It says invalid character in identifier
The error message:
Traceback (most recent call last):
File “/usr/lib/python3.6/py_compile.py”, line 125, in compile
_optimize=optimize)
File “”, line 741, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “./prog.py”, line 1
x,y = float(input()).split(’ ')
^
SyntaxError: invalid character in identifier
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python3.6/py_compile.py”, line 129, in compile
raise py_exc
py_compile.PyCompileError: File “./prog.py”, line 1
x,y = float(input()).split(’ ')
^
SyntaxError: invalid character in identifier