Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading