Dictionary | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Dictionary

So i have a dictionary and user input as an int and i want to know if the first thing in the dictionary corresponds to 0 and the second as 1 and so on. Is there a way to get that?

20th Aug 2016, 12:39 PM
Michael
3 Answers
+ 1
i=0 while i<len(dictionary) { if dictionary[i] == 1: #doSomething else: #doSomethingElse }
20th Aug 2016, 1:39 PM
HB Damienz
HB Damienz - avatar
0
@HB Damienz Thank you
20th Aug 2016, 2:35 PM
Michael
- 1
This Tutorial answer quite good to your question. Indexes for dictionary , lists and tuples start from zero.
20th Aug 2016, 12:53 PM
Marco Romanin
Marco Romanin - avatar