Python Forum
TypeError: sum() missing 1 required positional argument: 'num2'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: sum() missing 1 required positional argument: 'num2'
#1
def super_func(**kwargs):
    print(sum(kwargs))

super_func(num1 =1, num2=2)
Error:
TypeError Traceback (most recent call last) <ipython-input-195-6c0cf9eea71e> in <module> ----> 1 super_func(num1 =1, num2=2) <ipython-input-193-52558c3658cd> in super_func(**kwargs) 1 def super_func(**kwargs): ----> 2 print(sum(kwargs)) TypeError: sum() missing 1 required positional argument: 'num2'
Can you please help me with this error
buran write Jan-06-2021, 03:51 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
You need to look where this 'sum' function is defined. Obviously it is not the standard 'sum' function from the Python library.

Or you can perhaps try sum(**kwargs)
Reply
#3
Thanks a lot it worked fine. I altered the sum function by mistake.
Reply
#4
Thank you got it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: a bytes-like object is required ZeroX 13 3,838 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,858 Oct-17-2022, 06:29 PM
Last Post: paulo79
  TypeError: a bytes-like object is required, not 'str' - Help Please. IanJ 3 4,674 Aug-29-2022, 05:53 PM
Last Post: deanhystad
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,764 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,720 May-09-2022, 12:49 PM
Last Post: deanhystad
  What is positional argument self? Frankduc 22 5,493 Mar-06-2022, 01:18 AM
Last Post: Frankduc
  TypeError: missing a required argument: 'y' gible 0 2,846 Dec-15-2021, 02:21 AM
Last Post: gible
  positional argument: 'self' mcmxl22 8 3,195 Dec-13-2021, 10:11 PM
Last Post: deanhystad
  TypeError: missing 3 required positional arguments: wardancer84 9 10,663 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 1,938 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020