+ 2

# [ASSIGNMENT] Take a list of integers and split each integer into two more integers forming a new list that's twice as long.

"Write a function named split that accepts a list of integers as a parameter and returns a new list twice as large as the original, replacing every integer from the original list with a pair of integers, each half the original. If a number in the original list is odd, then the first number in the new pair should be one higher than the second so that the sum equals the original number. For example, if a variable named a refers to a list storing the values [18, 7, 4, 24, 11], the call of split(a) should retur

2 Answers

+ 10

import math
a = [18,7,4,24,11]
b = []
for i in a:
b.append(math.ceil(i/2))
b.append(math.floor(i/2))
print(b)

+ 3

a = [18,7,4,24,11]
split=lambda a:[a[i//2]//2+(a[i//2]%2,0)[i%2] for i in range(len(a)*2)]
print(a)
print(split(a))
https://code.sololearn.com/chCw1Mrd2uQK/?ref=app