0

I tried passing in a dictionary into a threading function

enemy_movement_thread = threading.Thread(target=enemy_movement, args= data)
enemy_movement_thread.start()

but an error occurred:

Exception in thread Thread-8:
Traceback (most recent call last):
  File "C:\Users\ryanc\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
    self.run()
  File "C:\Users\ryanc\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
TypeError: enemy_movement() takes 1 positional argument but 7 were given
Random Davis
  • 6,662
  • 4
  • 14
  • 24
  • So, `data` is either a list or a tuple with 7 items. If your `enemy_movement` function expects that list as a single parameter, then you need `threading.Thread(target=enemy_movement, args=[data])`. – Tim Roberts Apr 08 '21 at 16:58
  • Thank you very much! – Zeus0109 Apr 08 '21 at 23:50

0 Answers0