Divide by , and go to int() :
map(int, inputstring.split(','))
This creates a list; if you need a tuple, just wrap it with tuple() :
tuple(map(int, inputstring.split(',')))
In Python 3, map() returns a generator, so you should use a list view to create a list:
[int(el) for el in inputstring.split(',')]
Demo:
>>> inputstring = '1,-2,3,4,-5' >>> map(int, inputstring.split(',')) [1, -2, 3, 4, -5] >>> tuple(map(int, inputstring.split(','))) (1, -2, 3, 4, -5)
source share