官术网_书友最值得收藏!

Updating tuples

Tuple updating is not possible in Python, as tuples are immutable. But you can create a new tuple with an existing tuple, as shown in the following example:

#!/usr/bin/python3
cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')
numbers = (1,2,3,4,5,6,7)
tuple1 = cities + numbers
print(tuple1)

Output:
('Mumbai', 'Bangalore', 'Chennai', 'Pune', 1, 2, 3, 4, 5, 6, 7)
主站蜘蛛池模板: 阳泉市| 调兵山市| 东兰县| 祁连县| 昭苏县| 嘉祥县| 霞浦县| 海城市| 南平市| 涪陵区| 定结县| 沧州市| 霍山县| 岑溪市| 旬阳县| 佛山市| 古丈县| 凌源市| 遵化市| 乐至县| 安福县| 株洲市| 沁源县| 盈江县| 句容市| 长寿区| 江津市| 贡觉县| 察雅县| 蓝田县| 林州市| 门头沟区| 新晃| 阜平县| 桑日县| 三明市| 东乡| 金坛市| 西安市| 镇江市| 海林市|