Knowledgebase

Running Your First Python Script Print

  • python, errors, guide, howto, solution, zillionkinghost, hosting, support
  • 0

The basic workflow.

THE SEQUENCE

Write code in a file with a .py extension Save it Run it from a terminal Read the output or the error

HOW TO RUN IT

From a terminal, invoke Python followed by the filename.

WHAT HAPPENS

The file is executed from top to bottom.

WHAT AN ERROR LOOKS LIKE

A traceback: several lines ending with the error type and message.

Read it from the bottom. The last line states what went wrong.

WHAT TO DO FIRST

Write something that prints a message, and run it.

That proves the installation works.

WHAT TO DO NEXT

Add a variable, then a condition, then a loop.

Small steps, each run and verified.

WHAT NOT TO DO

Write fifty lines before running anything.

WHY

When it fails you will not know which part.

WHAT TO BUILD AS A HABIT

Run frequently. Test small pieces.

WHAT TO KEEP

Your early scripts. They become useful references.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot