Append integer to beginning of list in Python
I have an integer and a list. I would like to make a new list of them beginning with the variable and ending with the list. Writing
a + list I get errors. The compiler handles
a as integer, thus I cannot use append, or extend either. How would you do this?
>>> a = 5 >>> li = [1, 2, 3] >>> [a] + li # Don't use 'list' as variable name. [5, 1, 2, 3]