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 years ago, Updated 2 years ago, 45 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


© 2024 OneMinuteCode. All rights reserved.