Syntax Error In My Code

At the end of my lines that include if, there is a red triangle that appears and replit thinks it’s an error but all it tells me is “SyntaxError: expected ‘:’” when I try to run my code. please tell me how to fix this

Current behavior:

Desired behavior

Repl link:

code snippet

Hey @elvines, welcome to the community!

I’ve found your Repl, but please include the link yourself next time.

In Python, you need to have colons (:) after your if and else statements. You also need to indent the next line(s).
Also, after you use +=, -=, *=, /=, or anything else, you don’t need to put the name of the variable in parentheses because int/floats aren’t functions, just values.
Also also, on line 11, you are comparing total (an int) to (50) (a tuple). So just get rid of the parentheses.

Hope this helps! Just lmk if you have any other questions.


I will just kind of recreate it for you since there are some errors in it.

There it is worked out but I will explain it to you too.
To the right, there are comments on what it does as well if you need them.
I have changed your names to just normal letters for ease of use.
Asking The Questions:
I took the A and made it Equal to the input statement. In the input statement, I asked the user for how many tickets they would like for a child. and after they answer it goes to the next question and asks them how adult tickets they would like.
Doing The Math:
First I made their answers into an integer turning them into a number so we can add and multiply them. I made X equal to the amount per child ticket so that you can change the amount if you need to. I then made Z the amount per adult for the same reason as before. Now we do some actual math. I took the number and multiplied them using , so I did C is equal to A times () X, and now C is the answer to it. then I do the same thing for the children’s tickets. I then added them together for a total. E is equal to C plus D making E the variable for it.
IF statement:
In the IF statement, it says that if the number is greater than 50 then subtract 10 from it using e -= 10 and then print out the receipt
ELSE statement:
Under the else statement, it just is the printed-out version of the receipt. Instead of subtracting we just give them the receipt.
Important Notes:
You must make sure you put a : (Dubble dot) after you have an IF or ELSE statement.
You must have a TAB line under the IF and an ELSE statement.
If you have a : (Dubble dot) after you have an IF or ELSE statement it will TAB for you.
My code link:
You can copy and paste it if you would like to.
Extra Stuff:
This took me a while but I hope it helps you out. Also welcome to replit ask @elvines.

@elvines If my message worked or if someone else helps you and it works you should make sure that you hit the SOLUTION button under their message so you can help others with the same problem.

1 Like

How do you make those box things around something?

1 Like

Singular back ticks I believe (test => `test`)

1 Like

Thank you my friend

1 Like

There’s also triple back ticks (which are good for long code blocks):

def example(para=""):
  if para!="":

def example(para=“”):
if para!=“”:
(You can also specify a language!)

1 Like

Thank you to @QwertyQwerty54 and @Chandler0Bing for your replies. Now my code is running without errors.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.