Using While Loops and Incrementing Exercise Problem
Hello, the exercize attached the aforementioned was to create a while loops that produced odd numbers under 30. In my solution to the aforementioned exercise I wrote:
x = 0
while x <30:
Thanks for reaching out.
In its current state, the code will print
0 endlessly because the condition
x < 30 remains true, as
x never increases. This would result in an infinite loop.
The line of code we used in the example:
x = x + 2 assures that in every following loop, the value of x will increase with 2. Therefore, x will increase until it reaches 20.
Hope this helps.