Simple Python Tutorial to introduce list, tuple and dictionary

Опубликовано: 06 Май 2026
на канале: Earth Walker
171
6

Simple Python Tutorial to introduce "list", "tuple" and "dictionary" #list #tuple #dictionary #python

Please like the video if it helps you :)

Simple python example and short video to illustrate how "list", "tuple", "dictionary" works and the differences between them.
a "tuple" is a scaled down version of "list" as it has lesser functionalities as it's content cannot be changed once created.
Understanding the use of "list" will enable the user to also understand how to use "tuple". "List" and "Dictionary" are both
container used to store many values of different data types. The way they store the items and the syntax to access them are a bit
different. A "list" stores data using position whereas a "dictionary" store data using "keys". You can sort the values inside a "list" but you do not sort values in a "dictionary" since they are not stored by sequence (position). For a dictionary, you can access an item directly by the "key" but for list, you need to know their postion. It is possible to store a "list" within another "list" or "dictionary" (nested "list" or "dictionary") and vice versa.

Apart from talking about the differences of accessing a "list" and "dictionary", the video also show how we can use a loop to traverse through a "list" or "dictionary". The ability of traversing (looping) through a "list" or "dictionary" is important as
that allow us to run through a huge amount of data through a loop to process them.

The construct of syntax of the "list" and "dictionary"
== Create empty ==
#list
nameOfList = []

#dict
nameofDict = {}

== Create initialise with values ==
#list
nameOfList = ["John", 1.75, 77.8]

#dict , use Key : Value pairs
nameofDict = { "Name": "John", "Height: 1.75, "Weight: 77.8 }

== Accessing an item or element inside ==
both uses [] to access
#list
var = nameOfList[ postition ]

#dict method 1
var = nameofDict[ key ]

#dict method 2
var = nameofDict.get( key , [default value if key don't exisit] )

#dict method 2 with default value when key don't exist
var = nameofDict.get( key , defaultValue )

== Updating an item ==
#list
nameOfList[ postition ] = newValue

#dict
nameofDict[ key ] = newValue

== Adding a value or element ==
#list
nameOfList.append( newValue )

#dict
nameofDict[ newKey ] = newValue

== Deleting a value or element ==
#list
del( nameOfList[ postition ] )

#dict
del( nameofDict[ key ] )

== Traversing or looping through the list or dictionary ==
#list when you just need the value
for var in nameOfList:
#var store the value of the elements
...

#list when you just need the value as well as the position
for pos in range( len( nameOfList ) ) :
#pos stores the position of the elements
#nameOfList[ pos ] stores the value of the elements
...

#dict method 1
for key in nameofDict :
#key stores the key of the elements
#nameofDict[ Key ] stores the value of the elements
...

#dict method 2
for key,value in nameofDict.items() :
#key stores the key of the elements
#value stores the value of the elements
...

The example used is very simple just to illustrate the mechanics of a "list" and "dictionary" so that hopefully it is easy for a beginner to understand.

You can use the link below to see some related videos
(Apart from watching the video, you can also show more info to read on the explanation.)
== More on how "for" loop works ==
   • Simple Python Tutorial to introduce "for" ...  

== More on how range() works ==
   • Simple Python Tutorial to introduce range(...  


Hope these inputs are helpful for you.

0:00 - Intro to "list", "tuple" and "dictionary", how to create them empty
01:04 - Initialise "list", "tuple" and "dictionary" with values
03:55 - Differences between "list" and "dictionary"
04:54 - Accessing element value within "list", "tuple" and "dictionary", all using []
06:01 - Adding value to "list" and "dictionary". Cannot add value to "tuple"
07:03 - Updating element value within "list" and "dictionary". Cannot edit value to "tuple"
07:45 - Deleting an element from "list" and "dictionary". Cannot value from "tuple"
08:30 - Traversing (looping) through elements within "list", "tuple" and "dictionary"

Keywords:
#python
#list
#tuple
#dictionary
#items()
#len()
#loop
#for
#range()
#tutorial
#short
#simple
#easy