##### Beginner having Syntax Error problem
 Beginner having Syntax Error problem RyanHo Unladen Swallow Posts: 1 Threads: 1 Joined: Sep 2020 Reputation: Sep-08-2020, 12:50 PM (This post was last modified: Sep-08-2020, 12:52 PM by buran.) Hello guys I am new to Python and I have overcome a problem.Can anybody help? I am trying to make a simple calculator. This is the code. ```x=int(input('Input first number.\n')); y=int(input('Input second number.\n')); a=int(input('What calculation you want to perform?\n 1 +, 2 -,3 *,4 / \n')); If a==1;print('The answer is ',x+y); If a==2;print('The answer is ',x-y); If a==3;print('The answer is ',x*y); If a==4;print('The answer is ',x/y);```And the error is SyntaxError: invalid syntax which is pointing to the "a" in line 4 of this programme. Reply Posts: 7,705 Threads: 137 Joined: Sep 2016 Reputation: Sep-08-2020, 12:56 PM there are number of issues in your codeit is `if`, not `If` it should be `:`, not `;`, e.g. `if a==1:print('The answer is ',x+y)` no need of `;` at the end of line one-line `if` are generally discouraged If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs Reply Naheed Not Blown Up Yet Posts: 62 Threads: 5 Joined: Aug 2020 Reputation: Sep-09-2020, 05:17 PM 1. there is no need of; at the end of the line in while coding in python. 2. write "if" instead of "If", remember its a programing language not English. 3. Try to re-structure your if statements. one line code is often disregarded. Reply cnull Programmer named Tim Posts: 10 Threads: 0 Joined: Sep 2020 Reputation: Sep-10-2020, 08:33 AM ```x=int(input('Input first number.\n')) y=int(input('Input second number.\n')) a=int(input('What calculation you want to perform?\n 1 +, 2 -,3 *,4 / \n')) if a==1:print('The answer is ',x+y) if a==2:print('The answer is ',x-y) if a==3:print('The answer is ',x*y) if a==4:print('The answer is ',x/y)``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Query Syntax Error hammer 2 202 Jan-03-2022, 02:30 PM Last Post: hammer I'm getting syntax error while using input function in def. yecktmpmbyrv 1 540 Oct-06-2021, 09:39 AM Last Post: menator01 Invalid syntax error(Predict Ethereum Price) lulu43366 2 685 Sep-24-2021, 01:24 PM Last Post: lulu43366 Line 42 syntax error..Help!!1 patpython 4 850 Sep-01-2021, 03:22 PM Last Post: deanhystad Unexplained Invalid syntax Error cybertooth 5 897 Aug-02-2021, 10:05 AM Last Post: cybertooth I have a syntax error! rohes_kaugummi 3 982 Jun-23-2021, 05:24 PM Last Post: deanhystad import module with syntax error Skaperen 7 1,271 Jun-22-2021, 10:38 AM Last Post: Skaperen near "(": syntax error Maryan 3 1,328 Jun-21-2021, 08:05 AM Last Post: ibreeden getting a syntax error and i don't know why ilikedofs 10 1,779 May-13-2021, 08:52 PM Last Post: deanhystad Even number code syntax error MrCeez 1 917 May-02-2021, 06:43 PM Last Post: Larz60+

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020