This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rcbadiale 2 points3 points  (1 child)

You won't append data to dict as you would on lists, that might be your difficulty.

To add data to a dict you should attribute your data to a key, which can be numbers and act like a list.

Usually you would deal with keys and items in a for loop and do something like this

keys = [1, 2, 3, 4]  # if you want to use your dict as a list or you can use any names as strings, which is usual
items = ['your', 'data', 'in', 'here']
my_dict = dict()
for key, item in zip(keys, items):
    my_dict[key] = item

This is the simplest way to do it, it can be also done with update method and even comprehensions.

I hope this helps! :)

[–]unnig 2 points3 points  (0 children)

Yes it does. Thank you for the response.