0

so today i was wandering on codewars and found this kata: https://www.codewars.com/kata/51646de80fd67f442c000013/train/python the problem itself seems to be quite easy, but as you can see (in the link):

stripUrlParams('www.codewars.com?a=1&b=2&a=2')
stripUrlParams('www.codewars.com?a=1&b=2&a=2', ['b'])

the first line is the function with only 1 parameter but the second is a function with two parameters, is that even possible to create such function?

1 Answers1

2

you can set a parameter to have a default value.

def example(a , b=3):
    return (a+b)

now b will be 3 unless stated otherwise:

print example(1)
#>>> 4
print example(1,b=4)
#>>> 5    or
print example(1, 4)
#>>> 5
foxyblue
  • 2,859
  • 2
  • 21
  • 29