New coder seeking help on passion project

Ive been following a tutorial to make a streetfighter clone and im so confused at this error message

(i dont know if people copy and paste all of their code but its all on my replit (support - Python Repl - Replit)

Traceback (most recent call last):
 , line 44, in <module>
    fighter_1.move(SCREEN_WIDTH, SCREEN_HEIGHT, screen, fighter_2)
TypeError: Fighter.move() takes 4 positional arguments but 5 were given

i think what the solution has to do with my vs def mov is this

    #move fighters
    fighter_1.move(SCREEN_WIDTH, SCREEN_HEIGHT, screen, fighter_2)


    #event handler

and def mov is

(class Fighter():
    def __init__(self, x, y):
        self.rect = pygame.Rect ((x, y, 80, 180))
        self.vel_y = 0
        self.jump = False
        self.attack_type = 0

    def move(self, screen_width, screen_height, surface, target):
        SPEED = 10
        GRAVITY = 2
        dx = 0
        dy = 0


I think the issue is that you have five arguments here

and four here

they need to be the same number

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

ok so how would i edit them to be the same?

you can delete an argument from a function with the backspace

or you can add an argument by typing it

Python accepts the self argument automatically, so this shouldn’t be an issue.

However I can’t run the repl due to fighter not being a .py file it seems, so I can’t confirm.

This error is strange, because it shouldn’t occur here, move method takes 5 positional arguments (but one is implied and is not passed explicitly - the object instance). So I cannot reproduce encountering it.

Could it be possible that file with Fighter class was modified, but not yet saved when you were running it?

you are right! sorry, the scattered snippets confused me

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.