Skip to main content
added 190 characters in body
Source Link
cs95
  • 406.3k
  • 106
  • 744
  • 797

You can also use a list comprehension:

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

Or, shorter,

>>> [k for k in newdict] [1, 2, 3] 

Note: Order is not guaranteed on versions under 3.7 (ordering is still only an implementation detail with CPython 3.6).

You can also use a list comprehension:

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

You can also use a list comprehension:

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

Or, shorter,

>>> [k for k in newdict] [1, 2, 3] 

Note: Order is not guaranteed on versions under 3.7 (ordering is still only an implementation detail with CPython 3.6).

edited body
Source Link

youYou can also use  a list comprehension !:

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

you can also use  list comprehension !

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

You can also use a list comprehension:

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 
deleted 1 character in body
Source Link
sixsixsix
  • 1.9k
  • 23
  • 20

So easy! justyou can also use list comprehension !

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

So easy! just use list comprehension !

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 

you can also use list comprehension !

>>> newdict = {1:0, 2:0, 3:0} >>> [k for k in newdict.keys()] [1, 2, 3] 
Source Link
sixsixsix
  • 1.9k
  • 23
  • 20
Loading