Modification and deletion of Python tuples

Source: Internet
Author: User

The element values in the 1-tuple are not allowed to be modified, but we can concatenate the tuples together

#!/usr/bin/python

Tup1 = (12, 34.56);

tup2 = (' abc ', ' XYZ ');

# The following modification of tuple element operations is illegal.

# tup1[0] = 100;

# Create a new tuple

Tup3 = Tup1 + tup2;

Print Tup3;


The result of the above example output:

(34.56, ' abc ', ' XYZ ')


2 deleting tuples

element values in tuples are not allowed to be deleted, but we can use the DEL statement to delete an entire tuple, as in the following example:

#!/usr/bin/python

Tup = (' Physics ', ' Chemistry ', 1997, 2000);

Print tup;

Del Tup;


This article is from the DBA Sky blog, so be sure to keep this source http://9425473.blog.51cto.com/9415473/1693772

Modification and deletion of Python tuples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.