I have a maybe stupid problem, but can't figure out how to solve it. So basically what I'm trying to do is to:
- Create a list
- Add items to the list (stored in a second list)
- Transform the list into a tuple
So I thought I would do something like this:
anotherList = [2,5,8]
myTuple = tuple([1,2,3].extend(anotherList))
This does not work as it throws the error:
TypeError: 'NoneType' object is not iterable
This makes sense, as the result of the extend
operation is not a list. The problem is that I wasn't able to make it in a one line code, but only in a 4 lines code, like that:
anotherList = [2, 5, 8]
myList = [1, 2, 3]
myList.extend(anotherList)
myTuple = tuple(myList)
Is there a way to simplify this code? It looks unnecessarily long!