
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Convert location coordinates to tuple in Python
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 −
Example
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)
Output
The string is : 67.5378, -78.8523 The coordinates after converting the string to tuple is : (67.5378, -78.8523)
Explanation
- A string is defined, and is displayed on the console.
- The 'eval' method is used, and the string is passed as parameter to it.
- This is assigned to a value.
- It is displayed on the console.
- Related Articles
- Convert String to Tuple in Python
- Convert Tuple to integer in Python
- Convert tuple to float value in Python
- Convert tuple to adjacent pair dictionary in Python
- Python program to convert Set into Tuple and Tuple into Set
- Convert Nested Tuple to Custom Key Dictionary in Python
- How to convert a list into a tuple in Python?
- How can I convert Python tuple to C array?
- How to convert JSON data into a Python tuple?
- How can I convert a Python tuple to string?
- Convert a list into tuple of lists in Python
- How to convert python tuple into a two-dimensional table?
- How can I convert a Python tuple to an Array?
- Python Pandas - Get location for a label or a tuple of labels in a MultiIndex
- How can I convert Python strings into tuple?

Advertisements