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

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)
主站蜘蛛池模板: 南宫市| 淳化县| 如东县| 通道| 淮阳县| 富宁县| 湘潭县| 山西省| 互助| 藁城市| 侯马市| 潮安县| 大名县| 深水埗区| 新蔡县| 凤冈县| 商丘市| 新民市| 阿图什市| 靖江市| 信宜市| 杭州市| 宁国市| 东源县| 永丰县| 娱乐| 澳门| 鄱阳县| 奉化市| 翁源县| 湖南省| 山丹县| 苏州市| 雷州市| 江油市| 常山县| 灵川县| 克拉玛依市| 缙云县| 安图县| 贵南县|