Function main()

Report a typo

Let's say you need a module that:

  • stores a string variable n with the value "42".
  • defines a main() function that prints the value of n.
  • calls the main() function only if it is executed as a script.

Put the lines of this module's code in the correct order and add indents. The first line of the program must be n = "42". NB: Use the buttons on the left to add indentation (one click equals four spaces).

Reorder lines using drag or arrows. Adjust indentation with left buttons
                def main():
              
                if __name__ == "__main__":
              
                n = "42"
              
                print("N:", n)
              
                main()
              
___

Create a free account to access the full topic