I would like to retrieve a set of data in a file in the form of a list.
The following is the data i am reading from the file which I want to add to list:
file input: (3,5),(5,2),(2,1),(4,2),(4,1),(3,1)
The following code shows what I have now:
with open("partial.txt") as f:
List = f.read().splitlines()
graph1 = ','.join('({0})'.format(w) for w in List)
print (graph1)
The output I get is:
>> (3,5),(5,2),(2,1),(4,2),(4,1),(3,1)
BUT I want the above result in [ ], like this:
>> [(3,5),(5,2),(2,1),(4,2),(4,1),(3,1)]
Can someone show what I need to do to get the above result