Coding in Python 05 - Lists and Dictionaries
Jump to navigation
Jump to search
Overview
In the fifth video of the Coding in Python series, Lists and Dictionaries are shown.
Relevant Links |
---|
Original Video |
Commands Used in this Video
Creating a simple list
turtles = ['michelangelo', 'raphael', 'leonardo', 'donatello']
Print the entire list
print(turtles)
Print a specific item from the list (starts counting at 0)
print(turtles[1])
Remove an item from the list
turtles.pop(1)
Add an item to the list
turtles.append("splinter")
Creating a dictionary
turtles = {'michelangelo':'party dude', 'raphael':'cool, but rude', 'leonardo':'leader', 'donatello:'geek'}
Print a specific item from the dictionary
print(turtles['donatello'])
Delete an item from the dictionary
del turtles['michelangelo']
Add an item to the dictonary
turtles["shredder"] = "mean dude"