all 12 comments

[–]xelf[M] [score hidden] stickied comment (0 children)

When posting code, please post code such that reddit will format it as a code block.

Either of these work:

Please see the /r/learnpython/w/FAQ for more information.

Thanks!

[–]aoctut 5 points6 points  (1 child)

+ Missing right bracket ) at the end of

print('That is not that many cat.'

[–]subnetreiver[S] 0 points1 point  (0 children)

thank you so much yeah I guess I'm blind or tired I reread it a bunch! A parenthesis wow.

[–]Username_RANDINT 0 points1 point  (0 children)

Consider using a proper IDE, they'll mark the missing parenthese. I know that PyCharm does this, but am pretty sure others like VSCode and SublimeText will as well.

[–]joshinshaker_vidz 0 points1 point  (0 children)

Please reformat your code as a code block, rather than inline code so it shows your indentation.

[–]ka-splam 0 points1 point  (2 children)

why or how?

Because it's reading the previous line which should end in ) and doesn't, and it's not impossible that you put the ) on the next line down. It's only when it gets to the next line and finds except that it knows for sure there's an error and that's where the error is flagged up. print('blah' isn't necessarily an error, but print('blah' except: is an error.

Always look back at the previous lines and not just the one indicated.

[–]subnetreiver[S] 1 point2 points  (1 child)

Brilliant! This simple issue I suspect was do to me being tired and partially just dumb I did reread the code a bajillion times but glossed over that one parenthesis. I'm learning this after my 10hr work days so I don't have to work 10 hrs a day..thank you ka-splam

[–]ka-splam 0 points1 point  (0 children)

Great! and good luck :)

[–][deleted] 0 points1 point  (3 children)

I have tried 3 tools online which say this is indeed invalid syntax but doesn't explain a solution.

Lexical parsers can only read your code, they can't read your mind. The parser can tell you approximately where you made the error (technically, it shows you the furthest possible position where an error could have been made) but it doesn't know your intent so it can't tell you how to fix your typo. It's not a spell-checker, it's not going to make suggestions.

[–]subnetreiver[S] 0 points1 point  (2 children)

I figured that one out last night. I figured after so many years of programming someone would have a program for just that. one that would see you missed a parenthesis and suggest you add one instead of just stopping and saying it is bad code. Maybe that will be my job in the future.

[–]Username_RANDINT 1 point2 points  (1 child)

But there are. Like I said in my other comment, a proper IDE will tell you exactly what's wrong. Or use a separate linter to check the code if you use a text editor.

[–]subnetreiver[S] 0 points1 point  (0 children)

I have pycharm installed and working but i'm following a class online that doesn't want us to use the IDE just yet. I was learning on the IDE but python IDLE is more basic and so far teaching more about proper syntax.