Python with Progate (dictionary, while statement, break, continue)
python progate learning course Ⅱ
dictionary
- How to retrieve elements from a dictionary list *
Extract the list using the for statement and perform processing
** for variable name in dictionary: **
Here, the key of the element is assigned to the variable one by one, and the value of the element can be retrieved using the variable to which the key is assigned.
while statement
- How to write a while statement *
Iterative processing while certain conditions are met
** while conditional expression: **
Update variable value and check before processing
If False, processing ends
Be careful not to get into an infinite loop, especially pay attention to indentation
break
Used for conditional branching such as if statement, while statement, etc. to forcibly terminate repetitive processing
numbers = [1,3,5,7,9]
for number in numbers:
print(number)
if number == 5:
break
console
1
3
5
continue
Unlike break, only the processing of the week is skipped
numbers = [1,2,3,4]
for number in numbers:
if number % 2 == 0:
continue
print(number)
console
1
3