How to check a number in a list using a for loop in Python? Examples + exercises
#python #forloops #forloopspython #countinginforloops #magicnumber
Exercises:
1. How many numbers are there in this list?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
2. How many of the number:
212
102
100
111
are there in the following list?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
Use a loop for to answer.
______________________________________________________________________________________
Note:
7:12 - I forgot to write a colon sign after NUMBER_TO_CHECK. I am sorry for that error.
Let's remember for loops. We were already talking about them in the first Python course.
How to count the number of elements in a list using a for loop in Python?
The list from the examples:
[19,3,19,22]
Sometimes we replace the iteration variable by the underscore.
How many numbers 19 are there in this list [19,3,19,22]?
We created a new variable and named it NUMBER_TO_CHECK in order to avoid the situation with a "magic number".
Python course #2 in English 9
Python programming language course in English
#underscore #pythonexercises #pythontasks #python程式設計語言 #python程式設 #程式設計語言 #程式設
Видео How to check a number in a list using a for loop in Python? Examples + exercises канала Olga Soboleva
Exercises:
1. How many numbers are there in this list?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
2. How many of the number:
212
102
100
111
are there in the following list?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
Use a loop for to answer.
______________________________________________________________________________________
Note:
7:12 - I forgot to write a colon sign after NUMBER_TO_CHECK. I am sorry for that error.
Let's remember for loops. We were already talking about them in the first Python course.
How to count the number of elements in a list using a for loop in Python?
The list from the examples:
[19,3,19,22]
Sometimes we replace the iteration variable by the underscore.
How many numbers 19 are there in this list [19,3,19,22]?
We created a new variable and named it NUMBER_TO_CHECK in order to avoid the situation with a "magic number".
Python course #2 in English 9
Python programming language course in English
#underscore #pythonexercises #pythontasks #python程式設計語言 #python程式設 #程式設計語言 #程式設
Видео How to check a number in a list using a for loop in Python? Examples + exercises канала Olga Soboleva
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Filtering in a loop: example + exercise 3](https://i.ytimg.com/vi/7IKC4prx9CM/default.jpg)
![Grundkonzepte der Programmiersprache Python](https://i.ytimg.com/vi/vzJFXiDaBWA/default.jpg)
![Summing elements in a list using a loop "for" in Python: example + exercise 6](https://i.ytimg.com/vi/ZL75f3jqsAs/default.jpg)
![Konditionale Schritte in Python: Aufgabe 5](https://i.ytimg.com/vi/QbFLe2f1Nc8/default.jpg)
![Buscamos el valor mayor en una lista usando la palabra clave None en Python: ejemplo + ejercicio 11](https://i.ytimg.com/vi/nydOjKo28VU/default.jpg)
![Порядок выполнения действий в программировании и математике](https://i.ytimg.com/vi/6BQNYYHYGjA/default.jpg)
![Palabra clave "in" en Python. ¿Cómo aplicar "in" a strings en Python?](https://i.ytimg.com/vi/Ah_iaC8w6pA/default.jpg)
![Order of operations in programming and mathematics](https://i.ytimg.com/vi/8KVWbptzwj4/default.jpg)
![Counting elements in a list using a for loop in Python: example + exercise 5](https://i.ytimg.com/vi/vtS12NIoAWU/default.jpg)
![Structure "try and except" in Python: exercise 1 - a hotel](https://i.ytimg.com/vi/jltzq6YUpf0/default.jpg)
![Creación del bucle "for" en Python](https://i.ytimg.com/vi/j-24VLm1HAE/default.jpg)
![Упражнения на циклы в Python - проверьте себя](https://i.ytimg.com/vi/BK_LsClDm1Q/default.jpg)
![Python: la estructura del curso número 1](https://i.ytimg.com/vi/x63Ic81f6xM/default.jpg)
![Strings in Python. String concatenation in Python.](https://i.ytimg.com/vi/HbrGRoD0Uww/default.jpg)
![Python: Struktur des Kurses Nummer 1](https://i.ytimg.com/vi/Y8ZRyG9no2k/default.jpg)
![Индексы в строках в Python: оператор индексации [ ]](https://i.ytimg.com/vi/t_KpQr7MXxI/default.jpg)
![Variablen in Python](https://i.ytimg.com/vi/of1DqlZ6_UY/default.jpg)
![Bauen eigene Funktionen in Python: die Übung "Die Punktezahl und die Note"](https://i.ytimg.com/vi/I10mUBJCOK8/default.jpg)
![Johann Sebastian Bach: Sinfonia No. 4 in D Minor (BWV 790), celesta sound](https://i.ytimg.com/vi/SeCViPj1XtM/default.jpg)
![Como abrir y leer ficheros en Python](https://i.ytimg.com/vi/OsapBqsvLgU/default.jpg)
![String libraries and string methods in Python; dir() function in Python](https://i.ytimg.com/vi/fDgjpyxhxFM/default.jpg)