The re-learning of python----Simple list (1)

Source: Internet
Author: User

Print ("Today to learn the list")

The # list consists of a series of elements arranged in a particular order. You can create a list of names that contain letters, 0-9 numbers, and all family members.
# Since lists generally contain a lot of things, the names are usually in plural form, letters, digits, names like this
# in Python, use [] to represent the list and use it to separate the elements.
Bicycles = [' Trek ', ' Cannondale ', ' redline ', ' specialized ']
Print (bicycles)
# The list is ordered and can be determined by the index or location of the element
Print (Bicycles[0])
# Plus. Title () capitalize more comfortable
Print (Bicycles[0].title ())
# When you don't know how long the list is, but you want to access the last element of the list, you can use [-1] to access it, which means starting with the last element
Print (Bicycles[-1].title ())
# you can use string concatenation to work with values in the list
Message = "Today I want to use" +bicycles[0].title () + "to go to school."
Print (message)
# Practice
# Save the name in the names and then visit it one by one, either by names[0],names[1], or by using for to access
# Add a greeting after the name
names = [' AA ', ' BB ', ' CC ']
For a in range (len (names)):
Print (names[a]+ "Say hello to You")


Learn a little every day ~

The re-learning of python----Simple list (1)

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.