188k views
3 votes
Consider the following code:

val = 0
while (val < 10):
val = val - 1
print (val)
What is the error?

User Tarek
by
7.9k points

1 Answer

2 votes

Answer:

The code will get stuck in an infinite loop.

Step-by-step explanation:

Since val is decreasing by 1 each time it meets the criteria of being smaller than 10, your code will get stuck in an infinite loop since val will always be smaller than 10.

Hope this helps :)

User Markwatson
by
6.6k points