What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-03 23:08:17
add item to tuple
tpl1 = ('BMW', 'Lamborghini', 'Bugatti') print(tpl1) #Now you have to add an item tpl1 = list(tpl1) print(tpl1) tpl1.append('Mercedes Benz') tpl1 = tuple(tpl1) print(tpl1) #*Run the code* >> ('BMW', 'Lamborghini', 'Bugatti') >> ['BMW', 'Lamb... Add solution -
Python 2021-11-02 05:19:09
create a named tuple python
>>> from collections import namedtuple >>> Person = namedtuple('Person', 'first_name last_name zip_code') >>> p1 = Person('Joe', 'Schmoe', '93002') >>> p1.first_name 'Joe' >>> p1[0] 'Joe' >>> p1.zip_co... Add solution -
Python 2021-10-25 15:47:08
merge two named tuples
from collections import namedtuple from functools import reduce def reducer( accum, d ): accum.update(d) return accum def tuplemerge( *dictionaries ): merged = reduce( reducer, dictionaries, {} ) return namedtuple('Merged', merged )(**merg... Add solution -
Python 2021-10-25 10:31:20
python tuples number Multiplication
set1=(70, 70) tuple(2*array(set1)) Add solution