Calling method from main with parameters

I want to be able to call the drawface() method from main using the specific parameters given. How would I do this?

It’s a little hard to understand what you mean here. Your call says drawface(center, size, win). But in the drawface function, center and win are already defined, and size isn’t used at all. So passing those parameters would have no effect.

Perhaps your intention is to do something like this:

def drawface(center, size, win):
    circ = Circle(center, size)
    circ.setFill("red")
    circ.draw(win)

def main():
    center = Point(100, 100)
    drawface(center, 30, win)

I’m not really sure how this fits into the rest of your code so I don’t know if this makes sense, this is just my guess.

Incidentally, it’s better if instead of posting a screenshot of your code, you copy and paste the actual code with a line of three backticks (```) before and after. Like this:

```
your code here
```

Then it will show up with proper formatting and people can copy and paste it, etc.

1 Like

Thank you I will take this into consideration

Analyzing your function drawface, it shows that it accepts three arguments. Namely: center, size, and win - at least where it is being called, - assuming their values are being defined in another part of your script. The function is missing these parameters in the header definition. Therefore, be sure to include these parameters when defining your function.

Now assuming that you have defined your function with these three parameters in the header, they are not being used because you are redefining them within the function body statements in the case for win and center. The argument size is not being used at all.

In order for the arguments to be useful, they need to be on the right side of the = sign within the function body statements. If they are on the left side, then they are being redefined (or overwriting the intended value).

I since have changed my parameters -namely center parameter- to fit into my program. Thank you