Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Python Invalid Syntax Error

43 + 9 * + 7 106

65 + 8 + * 7 SyntaxError: invalid syntax

Can some one please help.

  • + - Works
    • * - Doesn't work

Why do you have the * and + operators right next to each other? What are you trying to do?

2 Answers

I think the + sign is overloaded in meaning. It seems like in the first case the + is setting the sign of the number 7 for use in the multiplication.

As an example, try 43 + 9 * - 7 and notice the output is -20.

Thanks

Good question Brendan. Nothing useful. But i'm curious when this q? came up while learning precedence of operators and how come one can be executed and other cannot.

I don't know the answer.