Generate list of numbers and their negative counterparts A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python.

Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sorting it, yields [-b,1-b,2-b,…,-a,a,a+1,a+2,…,b]

Examples

\$a=6,b=9\$ gives [6,-6,7,-7,8,-8,9,-9] or [6,7,8,9,-9,-8,-7,-6] or [-8,7,-9,-7,9,8,-6,6] or [[6,-6],[7,-7],[8,-8],[9,-9]] or [[6,7,8,9],[-6,-7,-8,-9]] etc.

\$a=6,b=6\$ gives [6,-6] or [-6,6] or [[6,-6]] or [[6],[-6]] etc.
Python 2, 33 bytes



def f(a,b):print-a,a;a&lt;b&lt;f(a+1,b)


Try it online!

A recursive function that prints in a two-column format. Based on ideas from Surculose Sputum.

In Python 3, we'd need 2 more bytes for print() needing parens.



Python 2, 37 bytes



lambda a,b:range(a,b+1)+range(-b,1-a)


Try it online!

Unfortunately for this challenge, Python's ranges are exclusive, so we have to add 1 to both upper endpoints.