[Tutor] Type error when doing Pygame

David L Neil PyTutor at DancesWithMice.info
Sat Sep 28 06:20:37 EDT 2019


On 28/09/19 7:48 PM, Cravan wrote:
> Hi guys,
> 
>                  Recently tried doing a pygame project (which is still half-finished). However I received a TypeError code that 5 positional arguments have been inserted when I have only inserted four in my function. Have no idea why its not working.
...

> And here’s the Error I’m receiving:
> Traceback (most recent call last):
> 
>    File "final_project.py", line 135, in <module>
> 
>      g.run()
> 
>    File "final_project.py", line 37, in run
> 
>      self.draw()
> 
>    File "final_project.py", line 65, in draw
> 
>      self.food_food(screen, 5, 5, self.food_bar)
> 
> TypeError: food_food() takes 4 positional arguments but 5 were given


It's always worth looking carefully at the information contained within 
the Traceback. In this case, we're being told that the method is being 
given more arguments than it needs.

Should the first/"screen" argument be included?
(it does not appear to be used within the method)

-- 
Regards =dn


More information about the Tutor mailing list