Let’s say I have this function code:
def dosomething(thing1, thing2='hello', thing3='world'):
print(thing1)
print(thing2)
print(thing3)
When calling it, I would like to be able to specify what thing3 is, but without having to say what thing2 is. (The code below is how I thought it might work…)
dosomething("This says 'hello fail!'", , 'fail!')
and it would say:
This says 'hello fail!'
hello
fail!
So is there a way to do it like that, or would I have to specify thing2 every time I wanted to say what thing3 was?
Use keyword arguments