Hello!
First, do not use keywords as variable names. I mean
You can call list() built-in in the interpreter but in a script, you have to assign list() returns to a variable or use it as a callback.
The interpreter:
First, do not use keywords as variable names. I mean
dict
.You can call list() built-in in the interpreter but in a script, you have to assign list() returns to a variable or use it as a callback.
The interpreter:
In [1]: dict={'a':'aaa','b':'bbb','c':'ccc'} In [2]: list(dict.keys()) Out[2]: ['b', 'a', 'c']In script:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- my_dict = {'a':'aaa','b':'bbb','c':'ccc'} l = list(my_dict.keys()) print(l) print(my_dict.keys())Output:
Output:['a', 'c', 'b']
['a', 'c', 'b']