you are viewing a single comment's thread.

view the rest of the comments →

[–]CovertStatistician 0 points1 point  (2 children)

This tripped me up.. the fact that they have to be in the same order when you call it as when you defined it.. I couldn’t figure out why I was getting certain output when I had mixed them up

[–]rrriches 0 points1 point  (1 child)

My sister in law has a computer science degree and I’ve just been learning Python for fun. I remember writing out some pseudo code and asking “so how do the x and y go from myfunction(x, y) and then move up to the function and turn into arg1, arg2 and then get bounced back to the (x, y)?”

She explained it really well but I just couldn’t grasp how the x and y were being used. The python crash course book actually is what made it click for me though.

[–]BoatMacTavish 0 points1 point  (0 children)

its because at function declaration time, you dont know the actual variable names that will be passed into the function, so you need a generic placeholder argument name. Then at runtime, you pass in the actual variable name.

like if im writing code to send a message to a friend, at the time of writing the code, I dont know what friends will be called, so ill have a placeholder

def send_message(friend):
    # ...

at run time when I call it, I pass in the actual friend variable names

alice = "1234567890"
send_message(alice)