Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKonrad Gołda
735 PointsArguments vs. Strings
Hi,
can anyone explain what is the difference between arguments and strings?
In previous video, Craig pointed that argument is everything in between parenthesis, and strings are inside of the quotation marks.
Here in this Video, when he is explaining that we can print a statement constructed from few strings inside of parenthesis ("string", "string2", "string3"). With the knowledge from previous video I would say, that we can use multiple strings inside of one argument, but he is using the therms "string" and "argument" interchangeably like one was the synonym for the another.
Can anyone explain how it is in fact? Also, why Craig actually says so and is it his manner that will interrupt me learning from this course in the future videos? Feeling quite confused - not everything is explained as for a newbie. Let me express, that for you guys who have programming in a little finger those things might have no importance, but for new learners it is a really hard brain teaser.
2 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsSome terminology:
- a function is defined with one or more parameters
- a function is called by providing arguments
- during execution, the function parameters are assigned to the arguments provided in the calling statement
# Given a function,
def some_func(param1, param2, param3):
print(param1)
print(param2)
print(param3)
# called with three arguments:
some_func("string1", "string2", "string3")
In this case, each of the three strings is an argument of the function call.
- param1 is assigned to "string1"
- param2 is assigned to "string2"
- param3 i assigned to "string3"
The arguments do not have to be strings. Depending on the code within the function, each parameter may be expecting an argument of a certain type.
Post back if you need more help! Good Luck!
Konrad Gołda
735 PointsThank you guys for replying. Thanks Chris for explaining.
Kris, the video I was talking about is a video "Syntax and Errors" under this link: https://teamtreehouse.com/library/syntax-and-errors somewhere arount 4th minute.
KRIS NIKOLAISEN
54,972 PointsKRIS NIKOLAISEN
54,972 PointsCan you provide a link to the video? Is it this one?