When only Python a.pop() is executed, the result value is printed, but in the repetitive statement code, the output value is only printed.

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

a = [1, 2, 3, 4]

while a:

    a.pop()

Why doesn't the result come out when you run the code above?

If you just run a.pop(), the result value is printed, but the code above shows the output value only when you put it in print.

list python

2022-09-20 15:06

2 Answers

Did you run it in an environment like Jupiter laptop or Korab?


2022-09-20 15:06

By default, without the print command, your computer won't print anything.

Sometimes some consoles output objects, but... It's a function supported by the console, not by command.

And the condition of the while statement is set to a, and the command to end the loop is not set separately.


2022-09-20 15:06

If you have any answers or tips


© 2022 pinfo. All rights reserved.