Skip to main content

All Questions

Filter by
Sorted by
Tagged with
-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": [...
Ali Jafar's user avatar
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 ...
b8con's user avatar
  • 629
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': ...
mo_shun's user avatar
  • 315
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 ...
Codees's user avatar
  • 7
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 ...
Tito Candelli's user avatar
-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 ...
kflaw's user avatar
  • 424
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): ...
Tom Smith's user avatar
  • 371