0% found this document useful (0 votes)
26 views5 pages

Basic Features of Python I: For Loop in List Vs Dictionary

The document discusses for loops in Python and how they iterate through lists and dictionaries. For loops in lists iterate through the elements, while for loops in dictionaries iterate through the keys, with the values accessed through a dictionary reference using the key.

Uploaded by

Kurnia Setiyawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Basic Features of Python I: For Loop in List Vs Dictionary

The document discusses for loops in Python and how they iterate through lists and dictionaries. For loops in lists iterate through the elements, while for loops in dictionaries iterate through the keys, with the values accessed through a dictionary reference using the key.

Uploaded by

Kurnia Setiyawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Basic Features of Python I

Part2
 For Loop in List vs Dictionary
Bentuk umum for Loop di Python
for <var> in <iterable>:
<statement(s)>

Schematic Diagram of a Python for Loop


For Loop in List
Example:
For Loop in Dictionary
Example:

As you can see, when a for loop iterates through a dictionary,


the loop variable is assigned to the dictionary’s KEYS
For Loop in Dictionary
To access the dictionary VALUES within the loop, you can make a
dictionary reference using the key as usual:

You might also like