print(y * 3)
I have similar issue and still get some errors. I don't know what is wrong in the script, although I put the same operation.:
Vector2D(other * self.x, other * self.y)
class Vector2D:
def __init__(self, x: float | int, y: float | int):
self.x = x
self.y = y
pass
def __mul__(self, other: float | int) -> 'Vector2D':
if not isinstance(other, Vector2D):
raise ValueError("IncorrectType")
return Vector2D(other*self.x, other*self.y)
pass
When I try to test it by
def test_multiply(self):
p1 = Vector2D(1, 2)
mult = p1 * 5
self.assertTrue(mult == Vector2D(5, 10))
with self.assertRaises(ValueError):
mult = p1 * 'Alice'
I have an error: 'line 91, in test_multiply mult = p1 * 5
File "2552856375.py", line 34, in mul raise ValueError("IncorrectType") ValueError: IncorrectType