Python list [] Brackets

Source: Internet
Author: User

names = [' Jack ', ' Rose ', ' Tom ', ' Jerry ', ' Jerry ']print (names) print (Names[0]) names[0] = ' Adam '  # change print (Names[0]) Print (names[2:])  # from left to right all print (names[-3:])  # Right Start right all print (Names[:-2])  # from right to left all print (Names[1:3])  # Left-to-right slice print (names[-2:-1]) # Right-to-  left slice names.append (' Alex ')  # Add print (names) Names.insert (1, ' James ')  # Specify location Insert print (names) names.remove (' James ')  # Delete print (names) del names[1]  # Delete print (names) Names.pop ()  # Delete Last # Names.pop (1)  = =  del names[1]print (Names.index (' Tom '))  # Find Print (Names.count (' Jerry '))  # Statistics Names.reverse ()  # reverse order print (names) Names.sort ()  # Sort Symbols Alphabetically--   numbers--Letter print (names) names2 = [1, 2, 3, 4]names.extend (names2)  # Two List of merged print (names) del Names2

  

Python list [] brackets

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.