0
the code in the question gives error when run
float("210"*int(input("enter the number:")))
6 ответов
+ 2
input() returns a string. If you feed int() a string that has not the shape of an int (like "1.2"), it will cause an error. Convert the string to a float first, then to an int.
print(float(210*int(float(input("enter the number:")))))
0
it still gives an error "can't convert string into float"
0
Maybe you are typing 1,2 (comma) instead of 1.2 (dot)? Maybe you used quotes/double quotes in your input? Please give an example of input otherwise.
0
I tried the code in the Playground and no error occurs. When I added a print function (@Zen) and entered 2, I get the expected result. The code seems to be okay.
0
the error ' can't convert string into float' occurs, when you try to convert a combination of letters into a float and that doesn't work. But when you enter a number it should work.
In any case, your program seems to try to convert something that can't work.
0
It only errors if you put in one number. If you put in two, separated by a new line, it works fine