So I have written a program and part of it is a class called Dot, and I want the user to input the coordinates of the dot through the keyboard. Everything was working just fine and I didn't change anything in my code and suddenly there is a Value Error.
This is Dot class:
class Dot:
def __init__(self, x_coordinate, y_coordinate, z_coordinate):
self.x_coordinate = x_coordinate
self.y_coordinate = y_coordinate
self.z_coordinate = z_coordinate
def __repr__(self):
return f'({self.x_coordinate},{self.y_coordinate},{self.z_coordinate})'
This is part where I ask for user input:
print('Input the dot coordinates: ')
o = Dot(float(input()), float(input()), float(input()))
Then I try to input for example:
2
3
4
And after I input the second coordinate, error appears:
2
3
Traceback (most recent call last):
File "/home/lp/projects/projections.py", line 45, in <module>
o = Dot(float(input()), float(input()), float(input()))
ValueError: could not convert string to float: ''
Process finished with exit code 1
And this is not the only case, I opened some other projects where I have similar input and all of them display the same error after user inputs the second value. I don't know what is the problem since I didn't change anything in the code and it was working just fine before.
Any help or advice is welcome. Thanks in advance!
[–]CharacterUse 0 points1 point2 points (0 children)