Looping: Definite Iteration

The most common use for the range function is looping. In computer science, a loop is a structure that allows you to run a block of code multiple times without having to write that code over and over again. One type of loop that Python supports is the for loop:

for name in names:
    check_name(name)

This loop will execute for each name in the list. name is simply a temporary variable that will change on each loop.

Comments & Discussion

mosc0 on Oct. 29, 2019

great info. i knew a some about it but it unclogged my mind. one question though, I have seen them using range in def functions functions. do you have a video about this?

Austin Cepalia RP Team on Nov. 2, 2019

@mosc0 I’m not exactly sure what you mean? Can you provide a code example?

Become a Member to join the conversation.