Back to Freecodecamp

While Loop

curriculum/challenges/english/blocks/dictionaries-and-loops/while-loop-video.md

latest518 B
Original Source

--description--

In this video, you will learn how to work with while loops to repeat code blocks as long as a condition is True.

--questions--

--text--

What will be the output for the following code?

python
i = 1

while i <= 10:
    print(i)
    i += 1
print("Done with loop")

--answers--

md
1
3
5
7
9
Done with loop

md
1
2
3
4
5
6
7
8
9
10
Done with loop

md
2
4
6
8
10
Done with loop

md
1
2
3
4
5
6
7
8
9
Done with loop

--video-solution--

2