Example I have attributes as below:
a = [1,2,3]
b = [3,2,1]
r1 = 5
r2 = 6
How do I get:
foo = [1,2,3,3,2,1,5,6]
Example I have attributes as below:
a = [1,2,3]
b = [3,2,1]
r1 = 5
r2 = 6
How do I get:
foo = [1,2,3,3,2,1,5,6]
def combine(*args):
result = []
for arg in args:
if type(arg) is int:
result.append(arg)
elif type(arg) is list:
result += arg
return result
You have many options:
How @falsetru said:
foo = a + b + [r1] + [r2]
Or:
foot = []
foot.extend(a)
foot.extend(b)
foot.append(r1)
foot.append(r2)
Or:
foot = []
foot.extend(a)
foot.extend(b)
foot.extend([r1])
foot.extend([r2])
Or:
foot = []
foot.extend(a + b + [r1] + [r2])
You can know more about the lists here: Python Data Structures