Quantcast
Channel: Python list of tuples: increase number of tuple members - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Thales for Python list of tuples: increase number of tuple members

You can convert the tuple to a list, change it, and then converting back to a tuplea[0] = list(a[0])a[0].append("red")a[0] = tuple(a[0])Just loop this for the entire list and it should work

View Article



Answer by Dvip for Python list of tuples: increase number of tuple members

tuples are immutable so you cannot append().If you want to add stuffs you should use python lists.Hope, that might help you!

View Article

Answer by Matthias for Python list of tuples: increase number of tuple members

Since a tuple is immutable you have to create new tuples. I assume you want to add this additional value to every tuple in the list.a = [('1', 'hello', 'en'), ('2', 'hi', 'en')]color = 'red'a = [(x +...

View Article

Python list of tuples: increase number of tuple members

I have a list of tuples with the pattern "id", "text", "language" like this:a = [('1', 'hello', 'en'), ...]I would like to increase number of tuple members to "id", "text", "language", "color":b =...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>