Learn Python the Hard Way:リスト
663 ワード
myList.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
numbers = [1, 2, 3, 4, 5]
fruits = ['apples', 'bananas', 'pears', 'oranges']
mix_list = [1, 'bottle', 2, 'tornado', 3, 'django']
for num in numbers:
print "This is number: %d" % num
print "
"
for fruit in fruits:
print "A fruit of type: %s" % fruit
print "
"
for i in mix_list:
print "I got %r" % i
print "
"
elements = []
for i in range(0,6):
elements.append(i)
for i in elements:
print "Element was: %d" % i