How to convert a list of strings representing tuples to tuples of integers?

sonia

I want to convert

list_int=['(2,3)','(3,4)']

to integer coordinate points:

[(2, 3), (4, 8)]

I tried this code

list_int=['(2,3)','(3,4)']
for x in list_int:
    con= int(x0 for x in list_int)
    print con

and I am getting this error

TypeError: int() argument must be a string or a number, not 'generator'

I am new to Python.

Mureinik

I'd remove the start and end parenthesis, split each string, and then convert each element to an int:

result = [[int(x) for x in s[1:-1].split(",")] for s in list_int]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

convert a list of strings to tuples?

How can I sort a list of strings representing tuples?

How to convert list of tuples into list of strings with no commas

Convert list of strings of tuples to list of tuples

How to convert a list to a list of tuples?

Convert a list of strings to a list of tuples in python

Convert list of strings to list of 2-tuples of integers (& Comma seperated in Tuple)

How to convert this dictionary into a list of tuples?

how to convert input list of tuples

List of integers to pairs of tuples

Python: how to return a total into a list of tuples of integers?

How to order a list of tuples of integers in Scala

numpy how to load list of tuples having integers

How to turn a list of Int into a list of tuples representing consecutive ranges

Convert list of tuples into list of all the integers used in that list

How to convert a string of a list of tuples to a Python list of tuples

Python dict comprehension convert list of tuples of dictionaries and integers into list of dictionaries

Python list comprehension filtering with tuples (containing integers as strings)

Convert list of tuples to list?

Convert list of tuples to list?

Merge list of tuples and list of integers

How to convert list of dictionaries to list of tuples?

Python how to convert a list of dict to a list of tuples

How to convert a list of lists with tuples into a list of dictionaries?

List of strings to tuples

How to group a list of tuples based on the strings they contain?

How to sum tuples in a list of tuples?

Python convert list of nested tuples to list of tuples

Convert list of tuples into a dictionary with list of tuples