'TypeError: setcoords() missing 1 required positional argument: 'coords1'

full code with error message

I'm trying to do a class for drawing a triangle but apparently in line 29 there is a problem that i cant solve. I read some other question on here but they've been mainly about 'self' which is not my error

 def setcoords(self,coords1):
    self.coords=coords1


triangle.setcoords(((100,100),(150,200),(200,100)))
print (triangle.givecoords())
triangle.setcolor((0,255,0))
triangle.setvisible(True)
triangle.draw()


Solution 1:[1]

You have to create an Instance Objects:

my_triangle = triangle()
my_triangle.setcoords(((100,100),(150,200),(200,100)))

Class Names should normally use the CapWords convention and have a constructor (__init__):

class Triangle:
    def __init__(self, coords1):
        self.coords = coords1
    # [...] 
 
my_triangle = Triangle([(100,100),(150,200),(200,100)])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1