The task is to convert [1.5, 1.2, 2.4, 2.6, 3.0, 3.3]
into [(2, 1), (2, 3), (3, 3)]
Currently I use a bruteforce way to do it:
result = []
for i in range(0, len(nums), 2):
x = int(round(nums[i]))
y = int(round(nums[i + 1]))
result.append((x,y))
return result
Is there a more concise built in solution (e.g., using itertoools
)?