Please like the video if it helps you :)
Simple python example and short video to illustrate how work with a "list" and "dictionary". It illustrate firstly through an example to create a empty "list", then use a "for" loop to get user input and append the value to list. It then show how to use the loop to loop through the "list", access the content and perform some checks and processing. It shows some visualisation to depict how the content are stored in the list and how to we can use access the values. There are 2 methods of "for" loop used to illustrate the traversing of the list. It shows the simpler and more common method of getting the content first. The second method is using the range() method. The range() method is useful when you need to know the position within the list. It also show how you can name the [] notation to access content in the list. In fact the [] notation applies to both "list" and "dictionary" and it is important to be familiar with them when you try to access nested "list" or "dictionary". Knowing the [] notation, you can access any content in the nested "list" or "dictionary" directly (without using loop). Similar examples are done for nested or 2 dimension (2D) "list" and simple "dictionary"
The example are kept simple mainly used to illustrate how to work with a "list" and "dictionary". The focus on fundamental of working with the "list" and "dict". It is essential to get the fundamental before understanding or coming up with more complex program.
Some useful syntax (or notation) to work
###list
#Create empty list with []
nameOfList = []
#Create list with some content
nameOfList = [ value1, value2 ]
#use append() to add new value to list, newValue can also be a list or dictionary
nameOfList.append( newValue )
#use for loop to traverse through a simple list (1 D list)
for varName in nameOfList:
indent right 1st command in loop body
indent right #varName stores the value of the list
indent right ...
#use for loop to traverse through a nested list (2 D list)
for varName in nameOfList:
indent right 1st command in loop body
indent right #varName stores the inner list stored within nameOfList
indent right #varName[ pos ] are used to access element inside the inner list
indent right ...
###dict
#Create empty dictionary with {}
nameofDict = {}
#Adding a new value element to dictionary, , newValue can also be a list or dictionary
nameofDict[ newKey ] = newValue
#use for loop to traverse through a simple dictionary (1 D dictionay)
for varName in nameofDict:
indent right 1st command in loop body
indent right #varName stores the key of the dictionay, to get the value, use nameofDict[ varName ]
indent right ...
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.)
== Introduction to List, tuple and dictionary ==
• Simple Python Tutorial to introduce list, ...
== 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 - Creating empty "list" and add 5 elements into list
01:24 - Looping through "list" to check content with some specific criterion
02:32 - Create list within list (nested list)
04:29 - (method 1) Looping through nested "list" to check content with some specific criterion
05:50 - (method 2) Looping through nested "list" to check content with some specific criterion
07:34 - Creating empty "dict" (dictionary) and add 5 elements into list
09:15 - Looping through "dict" to check content with some specific criterion
Keywords:
#python
#list
#dict
#dictionary
#container
#len()
#input()
#append()
#lower()
#for
#loop
#loops
#range()
#nested
#nestedlist
#2Dlist
#2dimension
#2dimentional
#simple
#easy
#tutorial
Nesta página do site você pode assistir ao vídeo on-line Simple Python Tutorial to work with list and dictionary duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Earth Walker 20 Abril 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 182 vezes e gostou 6 espectadores. Boa visualização!