We help IT Professionals succeed at work.

IndentationError: expected an indented block

adbyits
adbyits used Ask the Experts™
on
Hi all i am having some massive brain farts at the moment and i cant work out the issue i am having, i have been starting at the code for hours and i know its on a small issue, i am getting a error on line 58, i know its got to do with formatting but for the life of me i ant get it to work correctly
#****
# *****
# VERSION 1.0
# DATE 6 Jan 2020
# UPDATED 6 Jan 2020
# *****


import mysql.connector
import pandas as pd
import mysql.connector
import urllib.parse
import requests
import finddatatime  # Getting the date from the second script called finddatetime.py

currentdatetime = finddatatime.date_time

print ("The Current time date is" + " " + currentdatetime)

from mysql.connector import Error
from __main__ import *

mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="A*****1",
    database="flightdata"
)

mycursor = mydb.cursor()

fnumber = (input("Please enter flight number:  "))

sql = 'SELECT * FROM flightdata.flightinfo where flightnumbers =' + "'" + fnumber + "'"
# print(sql)

mycursor.execute(sql)
# connection.commit()

myresult = mycursor.fetchall()

for x in myresult:
    flightnumber = x[3]
    orgin = x[10]
    dest = x[2]
    departtime = x[4]
    status = x[8]

answer = (input("Flight #: " + str(flightnumber) + " From: " + str(orgin) + " To: " + str(dest) + " At: " + str(
    departtime) + "is that correct? yes/no: "))
# if statment for answer start
if answer == "yes":
    print("Current status of your flight as of " + currentdatetime + " is " + str(status))
    # If statment for reminder start
    remind = (input("Would you like me to remind you of the status of your flight? yes/no: "))
    if remind == "yes":
    #some how start a loop to check the database for update and give open to exit
        else:
        if remind == "no":
         print("Thank you for using FLIGHT CHECK")
         quit()
    # if statment for reminder ends
else:
  if answer == "no":
    #answer will be moved to its own script so it can be reused
    print("UNDER CONSTRUCTION")
    quit()
    # if statment for answer end

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NorieAnalyst Assistant

Commented:
The only problem I can see is that some of the indentation seems off, try this.
import mysql.connector
import pandas as pd
import mysql.connector
import urllib.parse
import requests
import finddatatime  # Getting the date from the second script called finddatetime.py

currentdatetime = finddatatime.date_time

print ("The Current time date is" + " " + currentdatetime)

from mysql.connector import Error
from __main__ import *

mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="A*****1",
    database="flightdata"
)

mycursor = mydb.cursor()

fnumber = (input("Please enter flight number:  "))

sql = 'SELECT * FROM flightdata.flightinfo where flightnumbers =' + "'" + fnumber + "'"
# print(sql)

mycursor.execute(sql)
# connection.commit()

myresult = mycursor.fetchall()

for x in myresult:
    flightnumber = x[3]
    orgin = x[10]
    dest = x[2]
    departtime = x[4]
    status = x[8]

answer = (input("Flight #: " + str(flightnumber) + " From: " + str(orgin) + " To: " + str(dest) + " At: " + str(
    departtime) + "is that correct? yes/no: "))
# if statment for answer start
if answer == 'yes':
    print("Current status of your flight as of " + currentdatetime + " is " + str(status))
    # If statment for reminder start
    remind = (input("Would you like me to remind you of the status of your flight? yes/no: "))
    if remind == 'yes':        
        #some how start a loop to check the database for update and give open to exit
    else:
        if remind == 'no':
            print("Thank you for using FLIGHT CHECK")
            quit()
    # if statment for reminder ends
else:
  if answer == 'no':
    #answer will be moved to its own script so it can be reused
    print("UNDER CONSTRUCTION")
    quit()
    # if statment for answer end

Open in new window

To add to Norie... It is recommended to use always 4 spaces (no tabs) for one indentation level. If you are careful, you can use one tab for one indentation level. However, the tabs and spaces should not be mixed. Any decent editor supports "smart indentation" and you can usually pick that "only the spaces" should be used.

Author

Commented:
Thanks all i will look at it i am using pychgarm is ther something better i should b using

Author

Commented:
Norie thankks for that , i have tested and i am getting a error on line 50 expected an indent

Author

Commented:
IndentationError: expected an indented block
Analyst Assistant
Commented:
Try this.
import mysql.connector
import pandas as pd
import mysql.connector
import urllib.parse
import requests
import finddatatime  # Getting the date from the second script called finddatetime.py

currentdatetime = finddatatime.date_time

print ('The Current time date is' + ' ' + currentdatetime)

from mysql.connector import Error
from __main__ import *

mydb = mysql.connector.connect(
    host='localhost',
    user='root',
    passwd='A*****1',
    database='flightdata'
)

mycursor = mydb.cursor()

fnumber = (input('Please enter flight number:  '))

sql = 'SELECT * FROM flightdata.flightinfo where flightnumbers =' + ''' + fnumber + '''
# print(sql)

mycursor.execute(sql)
# connection.commit()

myresult = mycursor.fetchall()

for x in myresult:
    flightnumber = x[3]
    orgin = x[10]
    dest = x[2]
    departtime = x[4]
    status = x[8]

answer = (input('Flight #: ' + str(flightnumber) + ' From: ' + str(orgin) + ' To: ' + str(dest) + ' At: ' + str(
    departtime) + 'is that correct? yes/no: '))
# if statment for answer start
if answer == 'yes':
    print('Current status of your flight as of ' + currentdatetime + ' is ' + str(status))
    # If statment for reminder start
    remind = (input('Would you like me to remind you of the status of your flight? yes/no: '))
    if remind == 'yes':        
        # some how start a loop to check the database for update and give open to exit
        print('Loop to check database')
    elif remind == 'no':
        print('Thank you for using FLIGHT CHECK')
        quit() 
    # if statment for reminder ends
elif answer == 'no':
    #answer will be moved to its own script so it can be reused
    print('UNDER CONSTRUCTION')
    quit()
    # if statment for answer end

Open in new window

Author

Commented:
Thanks guys for all the help