I want to be able to insert numbers +1 , +2 based off the number in the list, directly next to that number it is based off of.
# existing list list1 = [1,10,100] #wanted output: [1,2,3, 10,11,12, 100,101,102] #I spaced out the output list for ease of reading/understanding what it is I want to do.
I would also like to be able to add up to +7 and more, so if it is possible please help make it efficient in this way.
You can use a simple nested comprehension:
list1 = [1, 10, 100] n = 3 # or 7 or whatever list2 = [x for y in list1 for x in range(y, y+n)] # [1, 2, 3, 10, 11, 12, 100, 101, 102]