Confused: syntax Error

**You must select a tag to post in this category. Please find the tag relating to the section of the course

am getting a syntax error error on my home coding practice. the python 3 compiler is complaining about the ‘=’ sign in the ‘<=’ logical operator as seen here. please help.

elif account > 35350 and >= 85650:    # <= 85650
                                          ^ 

you are on E.g. loops, learn-compatibility**

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

So, else if, account is greater than 35350 AND greater than or equal to 85650…

I think perhaps you mean <= 85650 (?)

1 Like

you are correct . the error was actually occuring regardless of < or >
so, elif account > 8700 and <= 35350:
^

What happens when we write this?

if a > b and > c:
    pass

Consider that the and/or statement joins conditions, these conditions have to be self-sufficient to begin with

if (valid_condition_1) and (valid_condition_2):

Also you can say:

if a > b > c:

but it’s good to understand both ways as they’re both useful,depending on context.

@sirtosti Tip: if you open your terminal and run python, you can input these commands quickly and see which is accepted and which throws an error. I often do this when I’m in doubt in the middle of a project (to not have to debug it later).

2 Likes

first of all, i forgot to thank you for the speed of your response. so thank you. am new to this. just learning

2 Likes

we’re always learning. So, in a sense, we’re all new.
:slight_smile:

1 Like

I forgot to say, Welcome to the forums!

1 Like

that is correct if you look at my correction below your last message . so my confusion is why the compiler is complaining about the ‘=’.

:tada: :tada: :confetti_ball: banzai!

thank you for the welcome

am using jupyter as my coding platform

Look at the and operator. You’re comparing two values. If both sides evaluate to True, then the and operator returns True. If either or both sides evaluate to False, then the and operator evaluated to False.

1 Like

that is correct. the problem is that am getting a syntax error on that line and in particular to the ‘=’ sign

what is the rest of your code in the control flow? Can you paste it?

if....elif...else

1 Like

SyntaxError: invalid syntax

let me post the rest of the code

elif account >35350 and <= 85650:
     Difference = account - 85650
        Table3a = Difference*(25/100)
        Table3 = Table1 + Tble2a   +    Table3a  

does that provide some clarity to the invalid syntax error?

Look back to what @lisalisaj and I wrote. We’re emphasizing the and operator.
Your code is very close to working.

but watch out for the spelling here as well, that may throw another error

Table3 = Table1 + Tble2a   +    Table3a 
elif account >35350 and <= 85650:

You should look out for these:

  • is account >35350 a valid condition by itself?
  • is <= 85650 a valid condition by itself?

From the earlier post:
if (valid_condition_1) and (valid_condition_2):

1 Like

i definitely will correct the spelling error, but am not sure the error with the ‘and’ operator that you point to