Syntax error with muliple if-Statements

python3

#1

Hello,

I have a syntax error, below here, the code and the error are there.
I am using Spyder3 as IDE with Python 3.5.2 and Ubuntu 16.10, all packages are up to date ...
Only for a completion ... But I don't understand why there are a syntax error with 3 if-Statements all working fine!

What is my failure? Please help me! Thank you very much!
The best greetings:
Jakob Krieger


## My code

# Enter the code of enter
entercodeinput = input("Enter the code of enter of the formula: ")
entercode = int(entercodeinput)

# Entercode 1 , Roots and y-intercept
if 1 == entercode:
  print("1: Roots and y-intercept")
  
  inputa = input("a = ")
  a = int(inputa)
  
  inputb = input("b= ")
  b = int(inputb)
  
  inputc = input("c= ")
  c = int(inputc)

  xrealminus = -2*c / b - math.sqrt(b**2 - 4*a*c)
  xrealplus = -2*c / b + math.sqrt(b**2 - 4*a*c)
  ximagminus = -2*c / b - cmath.sqrt(b**2 - 4*a*c)
  ximagplus = -2*c / b + cmath.sqrt(b**2 - 4*a*c)
  print("Real minus solution: ", xrealminus)
  print("Real plus solution: ", xrealplus)
  print("Imaginary minus solution:", ximagminus)
  print("Imaginary plus solution:", ximagplus)

# Entercode 2 , Vertex
if 2 == entercode:
  print("2: Vertex")
  
  inputa = input("a = ")
  a = int(inputa)
  
  inputb = input("b= ")
  b = int(inputb)
  
  inputc = input("c= ")
  c = int(inputc)

  x = -b / 2*a
  y = -1*(b**2 - 4*a*c)/4*a
  
  print("x-component of vertex: " , x)
  print("y-component of vertex: " , y) 
  
# Entercode 3 , Axis of symmetry
if 3 == entercode:
  print("3: Axis of symmetry")
  
  inputa = input("a = ")
  a = int(inputa)
  
  inputb = input("b= ")
  b = int(inputb)
  
  x = -b / 2*a
  
  print("Solution", x)
  
# Entercode 4 , Focus 
if 4 == entercode:
  print("4: Focus")
  
  inputa = input("a = ")
  a = int(inputa)
  
  inputb = input("b= ")
  b = int(inputb)
  
  inputc = input("c= ")
  c = int(inputc)

  x = -b / 2*a
  y = 1--1(b**2 - 4*a*c)/4*a
  
  print("x-component of vertex: ", x)
  print("y-component of vertex: ", y
  
# Entercode 5 , Directrix 
if 5 == entercode:
  print("5: Directrix")
  
  inputa = input("a = ")
  a = int(inputa)
  
  inputb = input("b= ")
  b = int(inputb)
  
  inputc = input("c= ")
  c = int(inputc)
  
  y = -1 * -1*(b**2 - 4*a*c) / 4*a
  print("Solution:", y)
  
# 42
if 42 == entercode:
  print("""The answer of the life, the universe and everything ...
... is here not needed! ;-""")

# No right input
entercodes = (1,2,3,4,5,42)

if not entercode in entercodes:
  print("Invalid input! Please run QPyES again!")

## The error:
  if 5 == entercode:
                   ^
SyntaxError: invalid syntax


#2

Can't have if-statements in argument lists. See previous line.


#3

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