Menu

Output

Common Output Errors

An output statement can look almost right and still stop your program dead. When Python meets a line it cannot make sense of, it stops with an error at that point, so the results that line should have printed never appear.

Three slips that stop the program

  • Unmatched quotation marks: a string must open and close with the same kind of quotation mark. print("Match over) opens a double-quoted string but never closes it, so Python keeps reading to the end of the line and fails.
  • Missing bracket: every opening bracket needs a closing partner. print("Kick off" starts the function call but never closes it, so Python reaches the end of the line still waiting for the bracket.
  • Incorrect capitalisation: Python treats capital and lower-case letters as different characters. PRINT is not the same name as print, so Python has nothing stored under it.

Text that isn't in quotation marks

Quotation marks are what tell Python to treat words as text. Leave them out and Python reads the word as a variable name, then looks for a stored value with that name. print(Full time) fails straight away because the space splits one name into two words. Even print(full_time) fails unless you have already assigned a value to full_time. Putting the quotation marks back prints the words themselves instead.

Here is a program carrying one of these slips. The string opens with a double quotation mark but there is no closing mark, so the string is never closed.

away_score = 3
home_score = 1
print("Away score: away_score, home_score)

Output:

SyntaxError: unterminated string literal (detected at line 3) (line 3)

With the closing mark in place, the corrected program runs and prints the labels and the values held in the variables.

away_score = 3
home_score = 1
print("Away score:", away_score, "Home score:", home_score)

Output:

Away score: 3 Home score: 1

Practise this