Creation and use of Lists/Tuples (Python)

--Originally published at My B10g

Tuples:

tuples gather information all together but you cannot change it´s order or add and remove things in it, to make a tuple it only requires a name and the use of () parenthesis.

example:

months = ('January','February','March','April','May','June',\
'July','August','September','October','November','  December')
print(months)

Note: you can use “\” to jump a line and organize it better

Lists:

List also save data but in the case of lists you can reorganize the values and add more  using List_name.append(‘added value’), you can also erase values using del List_name[#].

example:

cats = ['Tom', 'Snappy', 'Kitty', 'Jessie', 'Chester']
print (cats[2])
cats.append('Catherine')
del cats[1]

print (cats)

more at: http://sthurlow.com/python/lesson06/

Poem of the day:

roses_are_red_violets_are_blue_god