mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-04 05:07:34 +03:00
don't overwrite list
problem: assigning a list of animals to the list variable overwrites the list function, so that later in line 531 the list function is not available and raises a Type Error: ``` In [133]: list(filled_dict.keys()) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-133-a2c520b90051> in <module> ----> 1 list(filled_dict.keys()) TypeError: 'list' object is not callable ``` solution: use another variable name instead of list
This commit is contained in:
parent
790bedf429
commit
898d9d43a3
@ -466,8 +466,8 @@ prints:
|
||||
1 cat
|
||||
2 mouse
|
||||
"""
|
||||
list = ["dog", "cat", "mouse"]
|
||||
for i, value in enumerate(list):
|
||||
animals = ["dog", "cat", "mouse"]
|
||||
for i, value in enumerate(animals):
|
||||
print(i, value)
|
||||
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user