How to make a dictionary from a text file with many elements?

37 Views Asked by At

I'm trying to make a dictionary for the text file Subscrition_Info.txt. the text file looks like this:

enter image description here

I need to make it into a dictionary named subscriptions, but I don't know how to because the list has more then 2 values.

Any ideas of how to solve this issue?

I have tried:

enter image description here but the code doesn't work and the error is :

enter image description here

1

There are 1 best solutions below

0
acrobat On

If the items you want are the first two from each row, you can store those to key & val and discard the remaining items with the following:

key,val,*_ = line.split(',')