Christian Christian - 10 months ago 49
Python Question

Syntax error when defining 2 functions in python

I've very new to programming so sorry if this is a stupid question, but I'm trying to make a program with multiple functions, but whenever I attempt to define one it comes up with an error.

def startUp():

def promptName():
name = input("Hello. Please enter your name: ")

SyntaxError: invalid syntax

If it helps the def part in def promptName(): is highlighted red.


I'd bet you're trying to paste the entire thing into a Python interpreter session. The command line interpreter needs things entered one block at a time, so try pasting the startUp function, hit enter, then promptName and enter, and then run the whole thing with the last line.

Alternatively, save it all as a .py file and run the file.