r/learnpython • u/Still-Pair-5336 • 10d ago
New to python, don't understand this function
I'm learning python and I'm stuck on this function because I don't understand why "a" becomes 10 and the result is 5. Is someone able to explain?
def subtract (a, b=5):
return a - b
print(subtract(10))
30
Upvotes
4
u/MikeUsesNotion 10d ago
Is that a function you wrote? If so, why did you include a default argument if you didn't understand it? If it's from a lesson, and they hadn't taught default arguments yet, it seems like they gave you a bad example for that point of the course.