All Questions
7 questions
-2
votes
1
answer
431
views
Append multiple values for one key from a dictionary?
I am new to python I have a dictionary which has many duplicate keys
{'key1': 'value1', 'key2': 'value2','key1': 'value3', 'key3': 'value4','key1': 'value5'......}
want output like this
{
"key1": [...
0
votes
2
answers
712
views
How can I create a dynamic dictionaries in Python using a CSV file
The problem is simple, I have a CSV file with four columns I wanted to value of the first column and make that into a dictionary in my python script. I don't want to add values to the dictionary dates ...
0
votes
1
answer
300
views
Put dict into new list based on a key value in Python
I have data that looks like this:
[{'album': 'Lonerism',
'song': 'Led Zeppelin (Bonus Track)',
'datetime': '2014-12-10 08:03:00',
'artist': 'Tame Impala'},
{'album': 'Lonerism',
'song': ...
0
votes
6
answers
243
views
append lists in dictionary depending on another list python?
I have a dictionary like this with empty list as values
e = {'joe': [], 'craig': [], 'will' : []}
Then with this list below, I want to add the order of the names to the list inside the dictionary ...
0
votes
1
answer
149
views
Strange behaviour when appending items to lists inside dictionaries in python [duplicate]
I have a dictionary indexed by 201 integer keys (0..200). the value for each of these keys is a list. generated with the code below:
dictionary=dict.fromkeys(range201,[])
i am getting this strange ...
-4
votes
1
answer
2k
views
Why am I getting an error when trying to append values to dictionary key? [closed]
I am working on creating a dictionary from two lists, and the resulting dictionary will include some keys that have more than one value.
The two lists are jpg_paths and jpg_ID. I am iterating ...
2
votes
4
answers
779
views
Why are values of a two-level dictionary all pointing to the same object in Python 2.7?
I have tried to define a function to create a two-tiered dictionary, so it should produce the format
dict = {tier1:{tier2:value}}.
The code is:
def two_tier_dict_init(tier1,tier2,value):
...