S
S
Samad_Samadovic2021-06-11 12:38:40
Python
Samad_Samadovic, 2021-06-11 12:38:40

How to find the dictionary key by index?

Schedule = {'Monday':'', 'Tuesday':'', 'Wednesday':'', 'Thursday':'', 'Friday':''}
I have a dictionary /\
And I have index 3
How do I extract a key by index, without lists?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-06-11
@Samad_Samadovic

Bust. And even then only starting with CPython 3.6

M
Mikhail Krostelev, 2021-06-11
@twistfire92

No way. Read about dictionaries. information is not organized. You can't access the index. Only by key.
So there is no list here. Create a list days = [Monday. Tuesday, Wednesday...]
and get the data from the dictionary via Schedule.get(days[i-1])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question