I can't come up with idea how to get rid of quotes that come with every string in my list of tuples. Tried different approaches from internet, still nothing works for me. Could somebody please help me?
This is my exaple:
[('Alabama', 'Montgomery', '32.361538', '-86.279118'),
('Alaska', 'Juneau', '58.301935', '-134.41974')]
I need:
[(Alabama, Montgomery, 32.361538, -86.279118),
(Alaska, Juneau, 58.301935, -134.41974)]
May be what I need is just to read a file in different way:
My raw data, separated with tab:
Alabama Montgomery 32.361538 -86.279118
Alaska Juneau 58.301935 -134.41974
I read file with this command:
with open('city-data.txt') as f:
mylist = [tuple(i.strip().split('\t')) for i in f]
repr(..)(orstr(..)on lists/tuples), since areprbasically aims to produce an expression, that will generate the object in represents again. You can construct a string where the quotes are removed, but only for printing purposes.