The while loop in Python is used to iterate over a block of code as long as the test expression (condition) is true.
In this blog post, you will learn how to use a python list with while
loop.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Print the list using WHILE loop
i = 0 while i < len(my_list): print(my_list[i]) i += 1
Output:
1
2
3
4
5