0

I have one list that contains coordinates two elements that have a pair of coordinates each.

cords = ["lat1,long1;lat2,long2","lat3,long3;lat4,long4"]

I need to break each set of coordinates out of "cord" and turn it into its own list using a for loop to automate the creation of the new lists. The number of coordinate pairs can change so i need a for loop that can create new lists for x number of coordinate pairs in the original list.

Needed outcome:

cords1 =["lat1,long1 ; lat2,long2"]
cords2 =["lat3,long3 ; lat4,long4"]
ljmc
  • 4,830
  • 2
  • 7
  • 26
Mat
  • 1
  • 1
  • 2
    Don't do this. A list is already the perfect way to have a variable number of elements. Do `cords = [[c] for c in cords]` if you want to just put each `c` in its own sublist. – Samwise Sep 16 '22 at 17:27
  • What do you need a loop for when you can write: `cords1 = [cords[0]]; cords2 = [cords[1]]`? – quamrana Sep 16 '22 at 17:28

0 Answers0