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 trialJorge Delgado
1,460 PointsWhat's the difference between using () and [] for lists?
I've seen a couple of people using parenthesis instead of [] for lists, is there any difference between them? Thanks
3 Answers
Steven Parker
231,275 PointsBrackets [] will create lists, parentheses () create tuples. They can be used in similar ways, but one of the differences is that tuples are immutable.
There's a another course similar to this one called Introducing Tuples that you might enjoy.
Jorge Delgado
1,460 PointsThank you!
Victor Mercier
14,667 PointsLike Steven said, brackets will create what is known in other programming language as arrays and parenthesis will create what is known as tuples. If you want to learn more about the difference between tuples and lists, here is a I have a link for you: https://www.afternerd.com/blog/difference-between-list-tuple/
Rommel Rodriguez
2,548 Pointsin the video banner = list() the "word" list in front of the () make it a list and not automatically a tuple?
Steven Parker
231,275 PointsBoth types of symbols have different meanings when placed after an identifier. The meanings discussed above only apply when they are used by themselves.
Mark Nembhard
1,387 PointsMark Nembhard
1,387 PointsWhat is confusing is that the banner = list ("Congratulations") you have this little jump in knowledge I think, where you create a list from the word Congratulations that has been introduced in an unexplained way.I understand Tuples are different from list but there is no explanation on the use of "list("Congratulations")" example and this is confusing