sum_two sample solution parameter
For the sum_two_challenge notebook (link), the Solution class template only takes one parameter:
class Solution(object):
def sum_two(self, val):
# TODO: Implement me
pass
That should change to two parameters:
class Solution(object):
def sum_two(self, a, b):
# TODO: Implement me
pass
Otherwise a TypeError is raised with the message:
TypeError: sum_two() takes 2 positional arguments but 3 were given
Hey Mark, We can still solve this by using the variable argument syntax in the sum_two method
class Solution(object): def sum_two(self, *val): return sum(val)
Run the test cases and it will pass all of them. Appreciate any feedback from your side.
For the sum_two_challenge notebook (link), the Solution class template only takes one parameter:
class Solution(object): def sum_two(self, val): # TODO: Implement me passThat should change to two parameters:
class Solution(object): def sum_two(self, a, b): # TODO: Implement me passOtherwise a TypeError is raised with the message:
TypeError: sum_two() takes 2 positional arguments but 3 were given
def sum_two(self, *val): return val
you can enter multiple values when we use (*args) and (**kwargs) takes keywords arguments