码迷,mamicode.com
首页 > 其他好文 > 详细

A list is a sequence

时间:2014-07-11 09:01:06      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   os   2014   

Like a string, a list is a sequence of values. In a string, the values are characters; in a list, they can be any type. The values in list are called elements or sometimes items. There are several ways to create a new list; the simplest is to enclose the elements in square brackets ( [ ]):

[10, 20, ‘span’, [30,40]]

A list within another list is said to be nested. A list that contains no elements is called an empty list; you can create one with empty brackets, []. List that contain consecutive integers are common, so Python provides a built-in function to create them:

  bubuko.com,布布扣                     

range takes two arguments and returns a list that contains all the integers from the first to the second, including the first but excluding the second! With one argument, range starts at 0:

 bubuko.com,布布扣

If there is a third argument, it specifies the space between successive values, which is called the ‘step size’.

 bubuko.com,布布扣

 

from Thinking in Python

A list is a sequence,布布扣,bubuko.com

A list is a sequence

标签:des   style   blog   http   os   2014   

原文地址:http://www.cnblogs.com/ryansunyu/p/3834584.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!