Skip to content
    Hack The FutureHack The FuturePython Notes

    UNIT 02 · TOPIC 12

    for Loop

    A for loop visits each item in an iterable, such as a list or range.

    The idea

    for Loop, simply explained

    A for loop visits each item in an iterable, such as a list or range.

    01

    See the big picture

    How the idea flows

    Input or goalfor LoopPython result
    Understand the problemApply for LoopRun the codeCheck the output

    Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.

    02

    Everyday connection

    Real-life example

    ↗

    A teacher checks each student's submitted assignment one by one.

    03

    Learn by doing

    Python code example

    PYTHONExample
    names = ['Ari', 'Mina', 'Dev']
    for name in names:
        print('Hello', name)
    Expected resultHello Ari Hello Mina Hello Dev
    Try it: Change one value in the code, predict what will happen, then run it and compare your answer.
    04

    Keep this in mind

    Key takeaways

    • A for loop visits each item in an iterable, such as a list or range.
    • Think of a real problem where for loop could save time or organize information.
    • Test small changes and read the result carefully before moving to a bigger program.

    Quick self-check

    Can you explain it in your own words?

    What is the main idea of for Loop?

    A for loop visits each item in an iterable, such as a list or range.

    Where could you see this idea in everyday life?

    A teacher checks each student's submitted assignment one by one.

    Keep learning · Hack The Future