0

The first print line I use , end="" in has a red dot next to it and is marked as invalid syntax. The python code still works with no problems but the invalid syntax is always there.

I even copied directly from the lecture notes and it still marks it as invalid syntax.

What am I missing?

    print("s: ", end="")
3

I added a space in there and it took the flag away. The rest of the print lines without the space are not flag. I'm wondering if this is a bug with the IDE or am I not understanding something?

This fixed the first line:

    print("s: ", end="" )

UPDATE: I've logged back in this morning to find the invalid syntax flag is back even on my updated code. At this point I'm assuming it's a bug in the IDE.

ANOTHER UPDATE: I'm now starting to think my syntax check is using Python 2 and my terminal is using Python 3. That would explain why the code works but the syntax is flagged. I checked my Python version in the terminal and it came back 3.4.3.

    python --version

So I guess now my question is how do I change that to use Python 3?

FINAL ANSWER: Click "CS50 IDE", Preferences, under Project Settings and then Project, there is "Python Support" click that, in the second box do the drop down to select Python 3.

4
  • i'm having the same problem and it's killing me.
    – daniel ho
    Apr 30 '17 at 8:31
  • Glad I'm not crazy! It's going to be difficult finding syntax errors if it's always flagging this code as invalid.
    – Adam
    May 1 '17 at 16:02
  • did you finish the pset? i can't text my code if that invalid syntax keeps popping up
    – daniel ho
    May 1 '17 at 21:40
  • i fixed it. check the codes around the invalid syntax line. i went to check if the next line of my code have any invalid syntax and i found it, when i change the code the invalid syntax is gone. it might be a bug in cs50 ide for directing you to a line that have no syntax error but when it show invalid syntax there'll sure be a problem in your code. hope this helps
    – daniel ho
    May 1 '17 at 22:40
0

i fixed it. check the codes ontop or under the invalid syntax line. i went to check if the next line of my code have any invalid syntax and i found it, when i change the code the invalid syntax is gone. it might be a bug in cs50 ide for directing you to a line that have no syntax error but when it show invalid syntax there'll sure be a problem in your code. hope this helps

2
  • I'm curious if it stays that way. I've closed the file and opened it again to see it wasn't flagged anymore. Then later on the flag pops up again. I've also edited the line as I mentioned above to have it be removed. Then after closing the file and opening it again the flag came back.
    – Adam
    May 2 '17 at 17:53
  • I have updated my answer. It's as Meta mentioned, just a different location.
    – Adam
    May 3 '17 at 1:34
0

I was having this issue in PyCharm 2017.1.2 on a new system. Turns out I had simply not set up my Python interpreter. File -> Default Settings -> Project Interpreter -> [interpreter]

1
  • I found the setting in the CS50 IDE. THANKS!!
    – Adam
    May 3 '17 at 1:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .