-1

As I am sure you will be able tell, I am very new to programming, I am engineering student at University and I don't know where to go for help because I don't know how to diagnose the issue(s). I want this code to output the strings without quotation marks, parentheses, and the \n (I want a new line).

Attached are some images that may be helpful for solving this issue. When I run this program in Mac's Terminal, no parentheses, "\n", or quotation marks appear, it outputs as it should. Please respond if there is anything else you would require to solve this issue.

Thank you in advance, this is my first StackOverflow post.

Code: (https://i.stack.imgur.com/5O9Ob.png) Ouput: (https://i.stack.imgur.com/A8VzC.png)

I tried removing the parentheses and the parentheses from my print lines and this actually worked, but my professor requires them in order for the code to be readable and I like them there, it helps me stay organized. Plus, I know that it is supposed to work just fine because my Terminal did it no problem.

  • Welcome to Stack Overflow! Please post code as text, not screenshots. http://idownvotedbecau.se/imageofcode – Barmar Mar 31 '22 at 22:52

1 Answers1

1

It is likely that PyCharm is configured to use python version 2, whereas you are probably using python version 3 in your terminal. You should check PyCharm python interpreter configuration and set it to python3.

Here is a minimal example in a terminal to illustrate the difference between python 2 and 3 in such a case:

> python2.7 -c 'print "\nhey", True'

hey True
> python2.7 -c 'print("\nhey", True)'
('\nhey', True)
> python3 -c 'print("\nhey", True)'

hey True
> python3 -c 'print "\nhey", True'
  File "<string>", line 1
    print "\nhey", True
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("\nhey", True)?

(note that print is a function in python3, the parentheses are therefore required, further explanation here)

DemisB
  • 11
  • 3