0

I am trying to create an app that has three options.

If the user selects 1 then popchange will run, if the user selects 2 then housing will run, I need the app to continue to run until the user selected three and exits the app.

My code is below, but it keeps returning an error for syntax and I have no clue why.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

print("\nWelcome to the data analysis app")

choice = ''

while choice != '3':
   print("Select the file you want to analyze: ")
   print("[1]:Enter 1 for Population Data  ")
   print("[2]: Enter 2 for Houseing Data  ")
   print("[3]: Enter 3 to Exit the application")

choice = input("\n What is your choice?")

if choice == '1':
  popchange= pd.read_csv("PopChange.csv")
  popchange_selected = popchange[["Pop Apr 1","Pop Jul 1", "Change Pop"]] 
  print("You selected PopChange")
  print(popchange_selected.describe())

elif choice == '2':
  housing=pd.read_csv("Housing.csv")
  housing_selected = housing[["AGE", "BEDRMS", "BUILT", "ROOMS", "UTILITY","WEIGHT","NUNITS" ]] 
  print("You selected Houseing")
  print(housing_selected.describe()

elif choice == '3':
  print("You selected 3.")
  print("Thanks for trying the application")

else:
  print("Invalid input, try again")

can anyone tell me why this is giving me the error

elif choice == '3':
   ^
SyntaxError: invalid syntax        
3
  • The print function before "elif choice == '3':" has a missing parenthesis. You need to change that line to: print(housing_selected.describe()). Commented Nov 25, 2019 at 19:32
  • When you get a syntax error, always double check the line that it's telling you as well as the one above it. I usually find mine on the prior line. Commented Nov 25, 2019 at 19:32
  • oh, yeah I just kept looking at the elif statement, I didn't even see the line above. Thank you guys so much. Commented Nov 25, 2019 at 19:46

1 Answer 1

2

you are missing closing bracket in the line above error.

print(housing_selected.describe())
                                 ^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.