Computer Science
Computer Science
The statement print is spelled incorrectly. The program will execute the
first instruction correctly then crash when it reaches the error.
The correct code is:
name = input("What is your name?")
print("Hello, " + name)
Syntax errors can be tricky to spot. Consider this short Python program:
forename = input("What is your forename? ")
surname = input("What is your surname? ”)
print "Hello, " + forname + " " + surname)
The program will execute the first two instructions correctly then crash
when it reaches the first error in line 3.
The correct code is:
forename = input("What is your forename? ")
surname = input("What is your surname? ")
print("Hello, " + forename + " " + surname)