0

I've a List of Tuples which is created dynamically and hence, its length can vary. An example of this list is:-

mylist=[(18.521428, 73.8544541), (28.6517178, 77.2219388), (18.9387711, 72.8353355)]

Now, I need to call the great_circle() of geopy.distance, in such a way that I should pass all my tuples as the parameters. Something like this-

great_circle((18.521428, 73.8544541), (28.6517178, 77.2219388), (18.9387711, 72.8353355))

But unable to do so, because the function great_circle(*args, **kwargs) is expecting individual tuples instead of a list of tuples. It is raising following exception:-

TypeError: unsupported operand type(s) for +=: 'int' and 'list'

So, can you suggest how it can be done ?

Shubham
  • 27
  • 6

1 Answers1

0

You can do it in one line, as long as you are sure that your list contains exactly the same amount of input as required. Just do:

great_circle(*mylist)

The * Operator will extract your data from the list, which will be equivalent to what you want.

Hope this helps.

Seraph Wedd
  • 864
  • 6
  • 14