401,402 views
9 votes
9 votes
What is the error in the code below?

finished = False
while finished != False:
value = int(input("Enter a number"))
value = value * 3
print("The value is ", value)

User Erhun
by
3.0k points

1 Answer

16 votes
16 votes

Answer:

Since we have set the variable finished to False, the while condition will never be true the first time so the loop is never executed

This can be fixed by changing the first line to
finished = True

or changing the while condition to

while finished ! True:

However, that does not solve the problem. There is no way to change the value of finished once inside the loop so it becomes an infinite loop

You must choose some other while condition

Step-by-step explanation:

User Srini Karthikeyan
by
2.5k points