What's the answer, python?

What does the following Python code print out?

# python code start
answer = 0
while answer < answer:
    answer = answer + 1
print answer


The answer is 0.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

The body of the while loop never gets executed since 0 is not < 0. Therefore, answer remains unchanged.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...