Coding in Python 05 - Lists and Dictionaries

From LearnLinux.tv Wiki
Revision as of 23:45, 17 February 2019 by Jay (talk | contribs) (Created page with "== Overview == In the fifth video of the Coding in Python series, Lists and Dictionaries are shown. {| class="wikitable" |- ! Relevant Links |- | [https://youtu.be/q_KJeVCzVn...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump 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"