Appending First Value Of A List Into The First Value Of Another List; Python
Working in python 2.7.
I have two lists (simplified to make explanations clearer).
T = [[1,0], [1,0], [0,5], [3, -1]] B = [, , , ]
I would like to append the second list (B) so that the first value of the B list is appended to the first list in the T list and so on.
Ex- I want the output to look like:
T = [[1, 0, 1], [1, 0, 3], [0, 5, 2], [3, -1, 2]]
I've tried playing around with different types of append functions, but I haven't found anything that works. Knowing python, I'm sure there's a way.
map(list.extend, T, B)
or, if you prefer an explicit loop
for t, b in zip(T, B): t.extend(b)
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module