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 trial

Python Introducing Lists Meet Lists Welcome

Why do some list methods require () and some require [], why can't they just all be kept the same?

Why do some list methods require () and some require [], why can't they just all be kept the same?

thanks!

2 Answers

I believe you are confusing. Methods do take (), however you would only use [] to access an index.

list = [1, 2, 3]
print(list.pop(0)) # pop is a method from list, it will remove the item at index 0 which is the value 1 
# the list is now [2, 3]
print(list[0]) # this accesses the index 0 which is the value 2 since the value 1 is no longer in the list
Vincent Zamora
Vincent Zamora
3,872 Points

could it be you might be confused with tuples and lists?