Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

LoveMathFermat Group Title

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

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. peterdb Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    () is used by functions [] is used by lists

    • 2 years ago
  2. snark Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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

    • 2 years ago
  3. LoveMathFermat Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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!

    • 2 years ago
  4. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    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.

    • 2 years ago
  5. LoveMathFermat Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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

    • 2 years ago
  6. lh4219 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    () is an empty tuple, [] is an empty list

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.