About 50 results
Open links in new tab
  1. python - Add variables to tuple - Stack Overflow

    69 In Python 3, you can use * to create a new tuple of elements from the original tuple along with the new element.

  2. python - How to add with tuples - Stack Overflow

    Apr 10, 2013 · In Python 3, map is slightly different, so that the result is a tuple of sums with length equal to the shorter of a and b. If you want the truncation behavior in Python 2, you can replace map with …

  3. python - how to add value to a tuple? - Stack Overflow

    At least in Python, tuples are immutable. If you want to "add something to a tuple", why not use a mutable data structure from the start?

  4. python - Inserting an item in a Tuple - Stack Overflow

    Jan 3, 2017 · Welcome to functional programming. You're not updating a tuple, you're creating a new tuple from an old tuple. Use collections.namedtuple and it will be obvious that your're creating a new …

  5. Python add item to the tuple - Stack Overflow

    May 24, 2013 · I have some object.ID-s which I try to store in the user session as tuple. When I add first one it works but tuple looks like (u'2',) but when I try to add new one using mytuple = mytuple + …

  6. python - Append a tuple to a list - what's the difference between two ...

    Jul 2, 2015 · You can make a tuple of the contents of a single object by passing that single object to tuple. You can't make a tuple of two things by passing them as separate arguments. Just do (3, 4) to …

  7. python - Why does adding a trailing comma after an expression create …

    The question is about why a tuple is created, not about useful things that can be done with tuples. This answer is completely irrelevant. Also, Python 2.x's print statement did not actually handle tuple s …

  8. Adding Values From Tuples of Same Length - Stack Overflow

    Jul 23, 2009 · Rather than adding the 1st value to the 1st value and the 2nd to the 2nd, and returning a resulting tuple. Until now I've been using this rather tiresome method: coord = (coord [0] + change …

  9. python - Add another tuple to a tuple of tuples - Stack Overflow

    You can't---but you can redefine them, actually what you're doing is assigning a new tuple object to the existing variable foo (which happens to already hold another tuple object, but that's irrelevant).

  10. Python - Not sure how to append tuples to dictionary value

    ex_dict[key].append(tup) # where tup is the tuple you want to add to the list Note that you don't want to assign an append function call to anything, as that returns a None. Just executing the above line will …