+ 1
Dictionary
How to make each value of the list become a key for some dictionary values if I do not know how many values are in the dictionary
5 Answers
+ 6
You could use a for-loop to iterate over the list. On each iteration, add the element as key to the dictionary.
Mind that lists can contain duplicate values and that keys must be unique.
+ 6
aАлександр Ковяров ,
can you please provide:
> a sample of the input list and a sample of the expected output.
> your code attempt as a link to your code in playground
+ 5
Ratnapal Shende ,
please do not post a ready-made code here as long as the op has not shown his attempt here.
it does not really help to improve the coding skills of the op, better to give hints or tips.
+ 1
Lothar sure
0
Dictionary comprehension or zip or dict.fromkeys()
Careful:
Dictionary key are unique,