I want to create a list of paired numbers. For example, I have a list of numbers as follows:
a = [1, 4, 7, 10, 13, 16, 19, 21, 24, 27, 30]
I want to create a paired list like this:
paired_list_a = [[1,3],[4,6],[7,9],[10,12],[13,15],[16,18],[19,20],[21,23],[24,26],[27,29]]
That is, I want to skip the first element and pair the numbers with the one next to them with minus one.
I tried something like this but no luck
paired_list_a = [1, 4, 7, 10, 13, 16, 19, 21, 24, 27, 30]
row = [[a[i],a[i+1]-1] for i in range(len(a))]
but it is throwing IndexError: list index out of range
Can anyone help me with this?