Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

What's the difference btw () and [] in python!? Thanks in advance!

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

() is used by functions [] is used by lists
also a = [1,2,3,4,5] produces a list b = (1,2,3,4,5) produces a tuple lists can be modified after creation: a[2] = 7 is fine tuples cannot: b[2] = 7 results in an error
What are differences between tuple and list? When should I use list over tuple or the other way around? It looks like a list is better since you can modify the assignment of the elements inside the bracket. Thank you for your help!

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

You pretty much answered your own question. If you want a collection to be immutable (can't be changed), a tuple is a better choice. If you want the same type of collection to be mutable (changeable), a list is a better choice.
Thank you guys for the help! I recently started to watch this course to learn some of program language. When listening to lectures, everything sounds straight forward, but when trying to solve problem sets, everything turns into a mess! haha
() is an empty tuple, [] is an empty list

Not the answer you are looking for?

Search for more explanations.

Ask your own question