When it is required to convert the location co-ordinates into a tuple format, the 'eval' method can be used.
The 'eval' method parses the expression which is passed to it as an argument. It executes that arguments as the code. It returns the result which is evaluated from the 'expression', i.e the parameter.
Below is a demonstration of the same −
my_string = "67.5378, -78.8523" print("The string is : ") print(my_string) my_result = eval(my_string) print("The coordinates after converting the string to tuple is : ") print(my_result)
The string is : 67.5378, -78.8523 The coordinates after converting the string to tuple is : (67.5378, -78.8523)