How to append rows in a python list?

How to append rows in a python list?

Just append directly to your original list:

# Create an empty list
my_list = []
values1 = [32, 748, 125, 458, 987, 361]
my_list.append(values1)
print(my_list)

values2 = [42, 344, 145, 448, 187, 304]    
my_list.append(values2)
print(my_list)

And this will be your output:

[[32, 748, 125, 458, 987, 361]]
[[32, 748, 125, 458, 987, 361], [42, 344, 145, 448, 187, 304]]

Hope that helps!

How to append rows in a python list?

Leave a Reply

Your email address will not be published. Required fields are marked *