Enjoy an ad free experience by logging in. Not a member yet? Register.

Results 1 to 3 of 3
Thread: Elif 'invalid syntax'

12172016, 06:23 PM #1
 Join Date
 Dec 2016
 Posts
 2
 Thanks
 0
 Thanked 0 Times in 0 Posts
Elif 'invalid syntax'
Code:import time print("The current time is", time.strftime("%H:%M"), ".") print("How may I help you? ") print("====================================") print(" [01] Addition ") print(" [02] Subtraction ") print(" [03] Multiplication ") print(" [04] Division ") print(" [05] Square a number ") print(" [06] Cube a number ") print(" [07] Find the area of a circle ") print(" [08] Find the volume of a sphere ") print(" [09] Count ") print("====================================") request = input() if request == ("1"): number1 = float(input("Please give me number. ")) number2 = float(input("Now the the second number. ")) number3 = number1 + number2 print ((number1),"plus",(number2),"is",(number3),".") elif request == ("2"): number1 = float(input("Please give me number. ")) number2 = float(input("Now the the second number. ")) number3 = number1 + number2 print ((number1),"minus",(number2),"is",(number3),".") elif request == ("3"): number1 = float(input("Please give me number. ")) number2 = float(input("Now the the second number. ")) number3 = number1 * number2 print ((number1),"times",(number2),"is",(number3),".") elif request == ("4"): number1 = float(input("Please give me number. ")) number2 = float(input("Now the the second number. ")) number3 = number1 / number2 print (((number1),"divided by",(number2),"is",(number3),".") elif request == ("5"): number = float(input("What would you like me to square? ")) squarenumber = number * number print ((number),"is",(squarenumber),"squared.") elif request == ("6"): number = float(input("What would you like me to cube? ")) cubednumber = number * number * number print (((mumber),"is",(cubednumber),"cubed.") elif request == ("7"): radius = float(input("What is the circle's radius? ")) pi = 3.14159265359 area = pi * radius * radius print ("The area of a circle with a radius of", (radius), "is" (area)".") elif request == ("8"): radius = float(input("What is the sphere's radius? ")) pi = 3.14159265359 volume = 4/3 * pi * radius * radius * radius print ("The volume of a circle with a radius of", (radius), "is" (volume)".") elif request == ("9"): i = 0 while True: add = int(input()) i += (add) print ("The running total is",(i),".") else: print("Huh? Type one of the numbers from the menu.")
This is my code. When I try to run it, it tells me that I have used incorrect syntax, on this part: elif request == ("5"): and all of those after it.
Could somebody help, because this seems like a common problem, yet I've found no actual answers.Last edited by vinyljunkie; 12172016 at 08:11 PM. Reason: added code tags

12172016, 06:31 PM #2
 Join Date
 Dec 2016
 Posts
 2
 Thanks
 0
 Thanked 0 Times in 0 Posts
It's all correctly indented on the actual program.

12182016, 08:47 AM #3
 Join Date
 Nov 2016
 Location
 South Africa, Cape Town
 Posts
 49
 Thanks
 1
 Thanked 1 Time in 1 Post
You have an incorrect number of parenthesis by ( if request == "4" ). You're also missing various data type separators in your print statements  meaning you're missing "," to separate your integers, floats and strings in some of the print statements.