Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sum_two sample solution parameter #296

Open
MarkMoretto opened this issue Jun 26, 2021 · 2 comments
Open

sum_two sample solution parameter #296

MarkMoretto opened this issue Jun 26, 2021 · 2 comments

Comments

@MarkMoretto
Copy link

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

@suhasthegame
Copy link

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.

@harsh1509c
Copy link

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

def sum_two(self, *val):
return val

you can enter multiple values when we use (*args)
and (**kwargs) takes keywords arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants