How do I Print a List's Keys?


#1

@discobot
how to print only “key” instead of “key: value” when programming on a list?


FAQ: Learn Python: A Day at the Supermarket - This is KEY!
#2

Hi! To find out what I can do, say @discobot display help.


#3

discobot is a bot, it only has few limited options. Its not capable of answering programming questions

Your question is confusing, a list only has values, no keys. key value pairs are for dictionaries


#4

my mistake. i was referring to “dictionaries”
how to only print "key"s but not pairs of key-value.

for example: dictionary = { “A”: 1 , “B”:2, “C”:3)
how to print only " A B C "?


#5

we have the keys method:

https://www.tutorialspoint.com/python/dictionary_keys.htm

or we could just loop over the dictionary, that would give us keys as well.