0
def main():
    print ("1=Square")
    print ("2=Triangle")
    print ("3=Rectangle")
    print("4=Circle")
    prob = input ("Enter the problem you have.")

This is the first portion of my code. When I remove the def main(): my program runs fine but when I add it I get this error

>>> C:/Users/dalel/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/dalel/Downloads/ap python project.py"
  File "<stdin>", line 1
    C:/Users/dalel/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/dalel/Downloads/ap python project.py"
      ^
SyntaxError: invalid syntax

Can anybody tell me what is going on please

  • 1
    Does this answer your question? [syntax error when using command line in python](https://stackoverflow.com/questions/13961140/syntax-error-when-using-command-line-in-python) – CrazyChucky Nov 08 '22 at 01:02

1 Answers1

0

Believe that your issue is the same as this one here. That you are trying to run the file from within the python interpreter. If it is, you can exit the python interpreter via exit(). And then from there, navigate to the directory where your file is located, then type:

python "ap python project.py"

Also make sure that you are calling the function at the end of your code via:

main()

Tested it in my environment and seems to work.

Conor Romano
  • 130
  • 10
  • 1
    Good work finding the target to point this to! Please flag rather than answering duplicates. (Duplicates aren't bad, but we like to have all the answers in one place, and point other phrasings of the same issue to that.) – CrazyChucky Nov 08 '22 at 01:03
  • 1
    Sounds good! This one actually still might be different enough due to also having the main() call... – Conor Romano Nov 08 '22 at 01:04
  • 1
    I could see that argument. On the other hand, I'd say that while that's helpful advice to give, it's not necessarily part of the question. They haven't even encountered that issue yet. One could flag to close as duplicate, and comment about calling `main()`. – CrazyChucky Nov 08 '22 at 01:14