Cannot see the csv but please don't use pictures in the future just cut and pasted a sample of the csv.
As I said before you need to change your indexing to 1
you have
you just want to use 1 as the index to get the item on its own
As I said before you need to change your indexing to 1
you have
noc_dict = {} line = 'AFG, Afghanistan' line = line.replace('\n', '') line = line.split(',') noc_dict[line[0]] = line[1:] print(noc_dict)which will output
Output:{'AFG': [' Afghanistan']}
because [1:] is a list of the 1 index and all the rest of the items if there are anyyou just want to use 1 as the index to get the item on its own
noc_dict = {} line = 'AFG, Afghanistan' line = line.replace('\n', '') line = line.split(',') noc_dict[line[0]] = line[1] print(noc_dict)
Output:{'AFG': ' Afghanistan'}