How to flatten the coordinates?
For input :[(1,2),(5,6),(7,8)]
expecting the output as [1,2,5,6,7,8]
How to flatten the coordinates?
For input :[(1,2),(5,6),(7,8)]
expecting the output as [1,2,5,6,7,8]
Try it like this:
mylist = [(1,2),(5,6),(7,8)]
newlist = []
for x in mylist:
newlist += x
print(newlist)
from the itertools doc page
from itertools import chain
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)