This will convert the dict_keys object to a list:

list(newdict.keys())

On the other hand, you should ask yourself whether or not it matters. It is Pythonic to assume duck typing -- if it looks like a duck and it quacks like a duck, it is a duck. The dict_keys object can be iterated over just like a list. For instance:

for key in newdict.keys():
    print(key)

Note that dict_keys doesn't support insertion newdict[k] = v, though you may not need it.

Answer from Chris on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_dictionary_keys.asp
Python Dictionary keys() Method
Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercises Code Challenge Python If...Else
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-dictionary-keys-method
Python Dictionary keys() method - GeeksforGeeks
June 3, 2026 - dict.keys() method in Python returns a view object that contains all the keys of the dictionary. The returned object is dynamic, meaning any changes made to the dictionary are automatically reflected in the view.
Discussions

How do I return dictionary keys as a list in Python? - Stack Overflow
I'm new to Python, and to me it seems that this proliferation of useless new datatypes is one of the worst aspects of Python. Of what use is this dict_keys datatype? Why not a list? ... @PhilGoetz it saves memory by creating a view onto the dictionary that can use all the dictionary's data, ... More on stackoverflow.com
🌐 stackoverflow.com
Python dictionary keys "new" syntax
You can use any hashable value as a key. It’s not a matter of syntax. More on reddit.com
🌐 r/learnpython
31
0
January 17, 2026
What is a "key" in Python dictionaries?
I have been struggling to understand the definition of a dictionary. In the Sololearn lessons, they keep using the word "key" when defining what a dictionary is. But the More on sololearn.com
🌐 sololearn.com
3
7
Printing Value of Dictionary As Int
Your question is not entirely clear and lacks details/context. Is this a dictionary you are defining? If so, why don’t you just store them as floats in the dictionary instead (it doesn’t seem like you actually want ints here)? Why are the keys of the dictionary numbered? Is this some ordering? Is it the quantity? Why store that information in the key rather than as a part of the value so the lookup is much simpler? It’s much easier to look up name than it is to look up index + “) “ + name + bunch_of_random_spaces I’m not trying to be rude to be clear. I’m just trying to get some context to help understand what your bigger ask really is More on reddit.com
🌐 r/learnpython
19
2
April 7, 2026
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.7 documentation
You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend(). It is best to think of a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one dictionary).
Top answer
1 of 13
1722

This will convert the dict_keys object to a list:

list(newdict.keys())

On the other hand, you should ask yourself whether or not it matters. It is Pythonic to assume duck typing -- if it looks like a duck and it quacks like a duck, it is a duck. The dict_keys object can be iterated over just like a list. For instance:

for key in newdict.keys():
    print(key)

Note that dict_keys doesn't support insertion newdict[k] = v, though you may not need it.

2 of 13
558

Python >= 3.5 alternative: unpack into a list literal [*newdict]

New unpacking generalizations (PEP 448) were introduced with Python 3.5 allowing you to now easily do:

>>> newdict = {1:0, 2:0, 3:0}
>>> [*newdict]
[1, 2, 3]

Unpacking with * works with any object that is iterable and, since dictionaries return their keys when iterated through, you can easily create a list by using it within a list literal.

Adding .keys() i.e [*newdict.keys()] might help in making your intent a bit more explicit though it will cost you a function look-up and invocation. (which, in all honesty, isn't something you should really be worried about).

The *iterable syntax is similar to doing list(iterable) and its behaviour was initially documented in the Calls section of the Python Reference manual. With PEP 448 the restriction on where *iterable could appear was loosened allowing it to also be placed in list, set and tuple literals, the reference manual on Expression lists was also updated to state this.


Though equivalent to list(newdict) with the difference that it's faster (at least for small dictionaries) because no function call is actually performed:

%timeit [*newdict]
1000000 loops, best of 3: 249 ns per loop

%timeit list(newdict)
1000000 loops, best of 3: 508 ns per loop

%timeit [k for k in newdict]
1000000 loops, best of 3: 574 ns per loop

with larger dictionaries the speed is pretty much the same (the overhead of iterating through a large collection trumps the small cost of a function call).


In a similar fashion, you can create tuples and sets of dictionary keys:

>>> *newdict,
(1, 2, 3)
>>> {*newdict}
{1, 2, 3}

beware of the trailing comma in the tuple case!

🌐
Analytics Vidhya
analyticsvidhya.com › home › what is python dictionary keys() method?
What is Python Dictionary keys() Method? - Analytics Vidhya
January 31, 2024 - Checkout our course on Introduction to Python! When it comes to performance, the keys() method is the most efficient way to retrieve dictionary keys as a list. It provides a view object that directly references the keys of the dictionary, without creating a new list.
🌐
Martin Fitzpatrick
martinfitzpatrick.com › tutorials › dictionaries
Python Dictionies, a rather long guide to Python's key:value hash type
June 2, 2026 - That includes mutable types including list and even dict — meaning you can nest dictionaries inside on another. In contrast keys must be hashable and immutable — the object hash must not change once calculated.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › dictionary_keys.htm
Python dictionary keys() Method
The Python dictionary keys() method is used to retrieve the list of all the keys in the dictionary. In Python, a dictionary is a set of key-value pairs. These are also referred to as "mappings" since they "map" or "associate" the key objects with
🌐
Google
developers.google.com › google for education › python › python dict and file
Python Dict and File | Python Education | Google for Developers
Python dictionaries, known as "dict", are efficient key/value hash tables represented by key:value pairs within curly braces {}.
🌐
Codecademy
codecademy.com › learn › dscp-python-fundamentals › modules › dscp-python-dictionaries › cheatsheet
Python Fundamentals: Python Dictionaries Cheatsheet | Codecademy
Values in a Python dictionary can be accessed by placing the key within square brackets next to the dictionary. Values can be written by placing key within square brackets next to the dictionary and using the assignment operator (=). If the ...
🌐
Built In
builtin.com › data-science › python-dictionary
Guide to Python Dictionary and Dictionary Methods | Built In
Dictionary keys can be any immutable data type, such as numbers, strings, tuples, etc, while dictionary values can be just about anything from integers to lists, functions, strings, etc.
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module2_EssentialsOfPython › DataStructures_II_Dictionaries.html
Data Structures (Part II): Dictionaries — Python Like You Mean It
Python’s dictionary allows you to store key-value pairs, and then pass the dictionary a key to quickly retrieve its corresponding value. Specifically, you construct the dictionary by specifying one-way mappings from key-objects to value-objects.
🌐
Programiz
programiz.com › python-programming › methods › dictionary › keys
Python Dictionary keys() (With Examples)
Here, dict_keys() is the view object and ['name', 'age', 'salary'] is the list of keys of the dictionary employee.
🌐
Python
wiki.python.org › moin › DictionaryKeys.html
DictionaryKeys
One simple approach would be to store a list of (key, value) pairs, and then search the list sequentially every time a value was requested. However, this approach would be very slow with a large number of items - in complexity terms, this algorithm would be O(n), where n is the number of items in the mapping. Python's dictionary implementation reduces the average complexity of dictionary lookups to O(1) by requiring that key objects provide a "hash" function.
🌐
Career Karma
careerkarma.com › blog › python › python dictionary keys: a complete guide
Python Dictionary Keys: A Complete Guide: A Complete Guide | Career Karma
December 1, 2023 - The Python dictionary keys() method returns all the keys in a dictionary. This method returns keys as a special object over which you can iterate.
🌐
Realpython
static.realpython.com › python-cheatsheet.pdf pdf
Real Python Pocket Reference Visit realpython.com to turbocharge your
Continue your learning journey and become a Python expert at realpython.com/start-here · Sets · # Creating Sets · a = {1, 2, 3} b = set([3, 4, 4, 5]) # Set Operations · a | b # {1, 2, 3, 4, 5} a & b # {3} a - b # {1, 2} a ^ b # {1, 2, 4, 5} Dictionaries · # Creating Dictionaries · empty = {} pet = {"name": "Leo", "age": 42} # Dictionary Operations · pet["sound"] = "Purr!" # Add key and value ·
🌐
Reddit
reddit.com › r/learnpython › printing value of dictionary as int
r/learnpython on Reddit: Printing Value of Dictionary As Int
April 7, 2026 -

Edit: Solved!

menu = {

'1) empty ': '$3.25',

'1) eggs ': '$3.25',

'2) bacon ': '$4.00',

'3) pancakes ': '$2.50',

'4) orange juice ': '$1.25',

'5) oatmeal ': '$3.99',

'6) milk ': '$1.25',

'7) donut ': '$2.00',

}

def get_price_of_menu_choice(x):

value = list(menu.values())[x] ## lookup item to get price

return(value) ## return price

Edit: How can i make the prices print as numbers without the quote marks??? This is part of a homework assignment but the course never covered dictionaries. The assignments asks you to print a menu in a specifically formatted way. Then lookup the item to return a price as a number ( float or integer). But currently it is printing with quote marks.

🌐
Claude Platform Docs
platform.claude.com › cli, sdks, and libraries › python sdk
Python SDK - Claude Platform Docs
Typed requests and responses provide autocomplete and documentation within your editor. If you'd like to see type errors in VS Code to help catch bugs earlier, set python.analysis.typeCheckingMode to basic. To convert a Pydantic model to a dictionary, use the helper methods: