Friday 25 May 2012

Initializing Lists

empty_list = []

string_list = [ 'a', 'list', 'of', 'strings']

number_list = [ 1, 1., 0]



list_of_lists = [  'empty_list', [ 1, 1., 0], string_list]

list_of_tuples = [ (1, 'a'), ('Fad', 'book'), ('Fade','book') ]








# append method built-in

string_list.append ('or letters')

#  I like lists because
#  they are simple and powerful

concatenating_lists = ['lists', 'are', 'versatile'] + [('and','fun')]

print string_list
print concatenating_lists









 P.Guo web application used as an illustrated print statement. Online Python Tutor
related blog entry

No comments:

Post a Comment