How do I separate the values using Python? I've tried split
and linespace
but they don't split the data in the way I'm expecting
My .txt file contains the following:
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating carcharias', 3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',}
I'm looking for an output key = [0,1,2,3,...]
Values = ['tench, Tinca tinca','goldfish, Carassius auratus',...]
or can I just somehow convert it into a dictionary? I've tried split using the argument (',') and it splits 'tench, but I want 'tench, Tinca tinca' as an output.
This is the code I'm stuck on
f = open('imagenet1000_clsid_to_human.txt', 'r')
x = f.read().lower().strip().split("',")
y = []
for i in x: (y.append(i))
print(y)