I have a set
set1= { '1', '2' }
I want to convert '1', '2' to int , like this :
set_new = { 1, 2 }
How can I do this in python?
I have a set
set1= { '1', '2' }
I want to convert '1', '2' to int , like this :
set_new = { 1, 2 }
How can I do this in python?
You can use set comprehension:
>>> set1={'1', '2'}
>>> set2={int(item) for item in set1}
>>> set2
{1, 2}