Reputation: 61
I have this question, probably a simple enough answer but I can't find anything on this issue.
I have a JSON file containing multiple keys:
{
"url": "https://farm8.staticflickr.com/7488/15664490410_3dc1a99796_b.jpg",
"location": {
"lat": 54.600225,
"lon": -5.920579
},
"id": "15664490410_3dc1a99796_b.jpg",
"description": "[u'Belfast', u'night', u'Belfast City Centre', u'River Lagan', u'County Antrim', u'Northern Ireland', u'LovinBelfast', u'bridge', u'arches', u'sculpture', u'reflection', u'nighttime', u'Nuala with the Hula', u'Beacon of Hope', u'illumination', u'water', u'cityscape', u'Belfast Waterfront', u'Waterfront Hall', u'600D']"
},
My plan is to extract the 'lat' and 'lon' values and store them in a python list but maintaining their pair.
Therefore
myList = [(54.600225,-5.920579),(0,0),(1,1)]..and so on
I was looking at the list.append() function but you can only pass in a single object, which I dont think is what I want.
Hopefully someone can help!
Thanks!
Upvotes: 0
Views: 1369
Reputation: 14674
Pass a tuple with the two values you want. The tuple is a single object.
myList.append((54.600225,-5.920579))
myList
is a list of tuples and you're adding one tuple.
Upvotes: 3