In an exercise I am asked to reorganzie a tuple. Given the tuple: temp = ( ("mandag", 16.0), ("tirsdag", 13.0), ("onsdag", 14.0), ("torsdag", 13.0), ("fredag", 15.0), ("lørdag", 13.0), )
I am supposed to write a function called data_reorganize which outputs the following tuple when printed:
(('mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'),(16.0, 13.0, 14.0, 13.0, 15.0, 13.0))
I have managed this, but my code seems too long and chunky:
def data_reorganize(a):
x = []
y = []
for i in a:
x.append(i[1])
x = tuple(x)
for i in a:
y.append(i[0])
y = tuple(y)
return y,x