Python 2.7.9 Demo - 014.列表List的定义、取值、遍历

 

#coding=utf-8

#!/usr/bin/python



list = ['a', 1, 'b', 2, 'c', 3];



print list[0];

print list[1:3];

print list * 2;

print list + list + list;



# 遍历

print('for each method 1 : ');

for data in list:

    print data;



print('for each method 2 : ');

for i in range(0, len(list)) :

        print list[i];

 

你可能感兴趣的:(python)