FOR LOOPS Flashcards
1
Q
What is a loop?
A
Loops are a useful control structure for repeating a block of code multiple times. There are several types of loops in most programming languages, but the most basic and commonly used is the for loop.
2
Q
A for loop in Python has the following syntax:
A
for item in iterable:
Here, item is a variable that takes on each value in the iterable one at a time, and the indented code block following the for statement is executed once for each value. An iterable is a data type that can be iterated over, such as a list, a tuple, or a string.
3
Q
Write out an example:
A