What this error means
You used parentheses () after a variable that contains a list, trying to call it like a function. Lists are accessed with square brackets [], not parentheses.
Common causes
- You used
()instead of[]to access list elements. - You overwrote a function name with a list (e.g.,
list = [1, 2, 3]thenlist()). - Confusion between function calls and indexing.
Example that causes the error
items = [10, 20, 30]
first = items(0) # TypeError: should be items[0]
list = [1, 2, 3] # Overwrote list() function
new_list = list([4, 5]) # TypeError: list is now a list, not a function
How to fix it
Use square brackets for list indexing:
items = [10, 20, 30]
first = items[0] # OK: uses square brackets
second = items[1] # OK
Don't overwrite built-in names
my_list = [1, 2, 3] # OK: different name
new_list = list([4, 5]) # OK: list() function still works
Remember: () for functions, [] for indexing
# Functions use parentheses:
result = len(items) # OK: len is a function
# Lists use square brackets:
value = items[0] # OK: indexing