Python - convert list of tuples to a list of int -



Python - convert list of tuples to a list of int -

i have

x = [[1], [2, 3], [1, (3, 5)], [(3, 9), 7, 5]]

and want

x = [[1], [2, 3], [1, 3, 5], [3, 9, 7, 5]]

how can this?

you accomplish through series of loops.

>>> x = [[1], [2, 3], [1, (3, 5)], [(3, 9), 7, 5]] >>> l = [] >>> in x: m = [] j in i: if isinstance(j, tuple): m.extend(j) else: m.append(j) l.append(m) >>> l [[1], [2, 3], [1, 3, 5], [3, 9, 7, 5]]

python list tuples

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -