• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Jessica Ehleben Shields

UX Expert, Visual Designer, Web Developer, Leader

  • Home
  • About
  • Design Process
  • Portfolio
    • UI Design
    • UX Design
    • Print Design
    • Visual Identity
    • Publishing Design
    • Multimedia Design
You are here: Home / Development / Lists, sets, dictionaries

Lists, sets, dictionaries

A discussion of the differences between lists, sets, tuples, and dictionaries in Python.

Comparison Chart

ListSetTupleDictionary
Orderedxx
Mutable (value can change)xxx
May contains duplicatesxx
Basic syntaxlist1 = []set1 = {}tuple1 = ()dict1 = {‘key’:’value’}
comparison of common features between Python lists, sets, tuples, and dictionaries

Table of Contents:

  • List
  • Set
  • Tuple
  • Dictionary

Lists (ordered data set)

A list is an ordered data structure that stores more than one value in one variable space. Imagine owning a 3 disc DVD collection that comes in one case. Reaching for one case gives you access to each of the individual discs once you open it.

In Python we create a variable to store the list, then include each value within brackets:

dm_series = ['Despicable Me', 'Despicable Me 2', 'Despicable Me 3']

To access these individual values, we use the index value. Think of lists as having an invisible number below each value. We use that number to access the value. For example:

dm_series = ['Despicable Me', 'Despicable Me 2', 'Despicable Me 3']
                   0                  1                 2

To access Despicable Me 2, call the list and include the index number in brackets:

dm_series[1]

Common ways to use lists:

  • Create an empty list: my_cars = []
  • Print a value:  print(my_cars[1])
  • Select a slice of the list: my_cars[0:1]

Sets (unordered data set)

Sets are collections of unique elements without any particular ordering. Ordering changes how we sort and modify collections. For example, using .pop() on a list removes the last item, but .pop() on a set removes a random element because there is no “last element”.

In Python, we create a variable to store the set, then include each value within parentheses.

my_cars = ('Mustang', 'Fusion', 'Escape')

Common ways to use sets:

  • Create an empty set: my_cars = set()      
  • Conver a list to set: my_car_set = set([”Dodge Ram,’Ford Fusion’])
  • Iterate over a set:
    colors = set([‘Pthalo Blue’, ‘Indian Yellow’, ‘Sap Green’])
    for color in colors:
    print(color)

Tuples (ordered, immutable data set)

Tuples store related pieces of information and are useful when you have two or more values that are so closely related that they will always be used together, like latitude and longitude coordinates. A common use for tuples is to return multiple values from a function.

Tuples are similar to lists in that they store an ordered collection of objects which can be accessed by their indexes.

Unlike lists and sets, tuples are immutable. You can’t add and remove items from tuples, or sort them in place.

Create a tuple in Python:

statue_liberty = (''40.689247, '-74.044502')

Dictionaries (unordered data set, stored with key)

Dictionaries store pairs of elements: keys and values. A database could store names and social security numbers as a dictionary because each social security number (key) is unique and is used to identify the name (value).

Create a dictionary with Python:

my_cars = {'Dodge': 1976, 'Ford': 1955, 'Toyota': 2018}

Common ways to use dictionaries:

  • Print a value: print(my_cars[Toyota]), answer is 2018
  • Iterate over a dictionary:
    Beatles_Discography = {“Please Please Me”: 1963, “With the Beatles”: 1963,
        “A Hard Day’s Night”: 1964, “Beatles for Sale”: 1964, “Twist and Shout”: 1964,
        “Help”: 1965, “Rubber Soul”: 1965, “Revolver”: 1966,
        “Sgt. Pepper’s Lonely Hearts Club Band”: 1967,
        “Magical Mystery Tour”: 1967, “The Beatles”: 1968,
        “Yellow Submarine”: 1969 ,’Abbey Road’: 1969,
        “Let It Be”: 1970}
    for album_title in Beatles_Discography:
        print(“title: {}, year: {}”.format(album_title, Beatles_Discography[album_title]))

Created in 2019Key Skills: eLearning, Instructional Plans, JavaScript & PHP & PythonDesign Type: Development

Footer

Skills & Competencies

2012 Vice Presidential Debate (7) Adobe Flash & After Effects (4) Adobe Illustrator (28) Adobe InDesign (29) Adobe Photoshop (9) Amazon Kindle (1) Assessment Design (3) Design Thinking (8) eLearning (11) Genesis Framework (5) HTML and CSS (16) Instructional Plans (1) Instructional Video (5) Invision & UXPin (2) JavaScript & PHP & Python (19) Leadership (5) Marketing & Advertisement (7) PowerPoint (4) Research (6) Shopify (1) Third Century Campaign (9) Universal Accessibility (6) WordPress (11)

Portfolio

  • Development (3)
  • Environmental Design (6)
  • Multimedia Design (8)
  • Print Design (24)
  • Publishing Design (6)
  • Research (4)
  • User Experience Design (8)
  • User Interface Design (17)
  • Visual Identity (9)

Learn More

  • About Jessica
  • My Design Process

Special Projects

  • Third Century Campaign
  • 2012 Vice Presidential Debate

Jessica writes about skills for academic success at collegestudysmarts.com

Jessica Ehleben Shields has 19 years of experience in visual design, web development, and higher education.

© 2025 All Rights Reserved · Contact · Connect on LinkedIn