There is a line like:

numbers = '68259640,86902941,41040730,86376448,59169047,77037959,80441051,83822347,90871250,90672483,89596230,88062037,86575434,84129427,76139274,74980634,65350893,60685291,55771316' 

We need to convert it into a tuple of the form:

 (68259640,86902941,41040730,86376448,59169047,77037959,80441051,83822347,90871250,90672483,89596230,88062037,86575434,84129427,76139274,74980634,65350893,60685291,55771316) 

Do not tell me how? To index for example 1 I got the value 86902941

  • one
    yet so can eval (numbers) - vadim vaduxa

2 answers 2

Split using the .split() method (you get a list of strings), then convert the strings into an int through a generator, then turn everything into a tuple:

 s = '68259640,86902941,41040730,86376448,59169047,77037959,80441051,83822347,90871250,90672483,89596230,88062037,86575434,84129427,76139274,74980634,65350893,60685291,55771316' t = tuple(int(item) for item in s.split(',')) print(t) # (68259640, 86902941, 41040730, 86376448, 59169047, 77037959, 80441051, 83822347, 90871250, 90672483, 89596230, 88062037, 86575434, 84129427, 76139274, 74980634, 65350893, 60685291, 55771316) 
     s = '1,2,3,4,5,6' t = tuple(map(int, s.split(','))) # t == (1,2,3,4,5,6)