Skip to content
Advertisement

How to fix double output in python

How do i fix a bug where Hello world! is printed twice?

The output:

{clear}Hello World! {clear}{clear}Hello World! The terminal is cleared [Finished in 3.4s]

The code:

JavaScript

Advertisement

Answer

clear does not clear the global list messages; it creates a new local variable that is assigned an empty list before going away when clear returns. Either use global

JavaScript

or use the clear method:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement