Hi guys,
This feels like something that should be possible in Python, and something that I feel like I should know how to do.
Image I have a list of numbers:
items=[10,20,30]
Let's say I wanted iterate over them and define two new variables, a and b.
a=[]
b=[]
for item in items:
a.append(item*10)
b.append(item*20)
I can also do this in two list comprehensions:
a=[item*10 for item in items]
b=[item*20 for item in items]
It feel like I should be able to do this in one single expression. Something like:
a,b=[(item*10),(item*20) for item in items]
Is this possible?
Thanks.