Python for Keyword
The Python for keyword is used to create a for loop. The for loop is used to iterate over a given sequence and executes a set of statements for each element in the sequence.
for iterating_var in sequence: statements
In the below example, for loop is used to print all elements of a given list.
MyList = [10, 20, 30, 40] print("MyList contains:") for i in MyList: print(i)
The output of the above code will be:
MyList contains: 10 20 30 40
❮ Python Keywords