Python Line Indentation error on line 24. Please Help!

I’ve written a program to try and make suggestions and provide some credit card tips. The program seems to be broken though. Around line 24 the python idle states that an unexpected indentation error happened around this line: if sw524Y == "Y":
print(“Credit card suggestion and credit card tips program”)

import sys
while True:
    try:
        rule524 = input("Have you opened 5 or more credit cards in the past 24 months? Please enter Y or N: ")
    except:
        print("Sorry, I didn't understand that. What did you just enter?" "Please try again") 
        continue
    else:
        if rule524 == "Y":
            ruleY()
        
        def ruleY():
            print("That's not great but you still have options: ")
            print("If you want you can wait until you meet the 5/24 rule and at the same time improving your credit: ")
            print("Try to keep your credit utilization under 30% because banks don't like it when you max out your card. ")
            print("While you are at it never draw money from an ATM with a credit cards. Banks see this as a high risk short term loan and many banks will charge you daily intrest just for having the loan.")
            print("If you try and open more cards you may get denied or have you accounts closed you be careful.")
            print("If you want a travel card if I were you I would get the Barclays AA card")
            cards1 = ["Chase Freedom", "Chase Sapphire Reserve", "Chase Sapphire Preferred", "American Express Gold Card", "Capital One Venture Card"]
            print("Some other great cards to look at are:", *cards1, sep='\n')

            sw524Y = input("Do you want the Southwest Companion Pass?: ")
                if sw524Y == "Y":
                    print("You need to wait because as good as that pass is as a person who is over the 524 you aren't getting it any time soon.")
                if sw524Y == "N":
                    print("You won't get it anyway. Good on you for knowing your limits. Give it time any you may get it one day.")
                if sw524Y != "Y" or "N":
                    print("Please enter valid data next time.")
                    
            cashback()

        def cashback():
            cback = input("Do you want cash back? Enter Y or N. ")
            if cback == "Y":
                print("Okay. I would get either the Arrival+ or the Capital One Venture. Both come with great sign up bonuses. ")
            if cback == "N":
                print("Maybe you would like a travel card like the Chase Sapphire Preferred.")
            if cback != "Y" or "N":
                print("I guess you don't want any card. Okay then.")

        if rule524 == "N":
            print("Good for you. Now just because you opened under 5 credit cards in the last 24 months doesn't mean you can get any card you want")
            print("Different cards have different rewards so I'm going to need to ask you what options you value most.")
            print("Since you are under the 5/24 rule the recommended rate is 1 card every three months for the most benefits")
            print("There are a few great cards but to get the most benefits you should also be under the 4/24 rule or 4 cards in the last 24 months")
            cardnumber = input("How many cards did you open in the last 24 months?: ")
                if cardnumber <= 2:
                    print("You seem to be on the path to some great cards. You have a lot of flexibility.")
                if cardnumber >=2:
                    print("You have less flexibility but you still have the oportunity to open some great cards")
                    
            cards1 = ["Chase Freedom", "Chase Sapphire Reserve", "Chase Sapphire Preferred", "American Express Gold Card", "Capital One Venture Card"]
            print("While you wait I would look at some of these great cards for the future:", *cards1, sep='\n')
            

            rule424 = input("Have you opened 4 or more credit cards in the past 24 months? Please enter Y or N: ")
                if rule424 == "Y":
                    ruleY2()

                def ruleY2():
                    print("At least you haven't opened 5 or more cards in the last 24 months but you are essentialy in the same place as the person in the 5/25 category")
                    print("You don't have the option of opening multiple cards in the span of a few months")
                    print("I would get the Ink Preferred card")

Have you solved this yet? The if-block should be in the same indent level as the preceding line.

            sw524Y = input('...')
            if sw524Y == 'Y':
                print('...')
1 Like

I don’t understand why you indented your if element in line 23 or other lines. I removed your redundant indentations in the following code.

import sys
while True:
    try:
        rule524 = input("Have you opened 5 or more credit cards in the past 24 months? Please enter Y or N: ")
    except:
        print("Sorry, I didn't understand that. What did you just enter?" "Please try again") 
        continue
    else:
        if rule524 == "Y":
            ruleY()
        
        def ruleY():
            print("That's not great but you still have options: ")
            print("If you want you can wait until you meet the 5/24 rule and at the same time improving your credit: ")
            print("Try to keep your credit utilization under 30% because banks don't like it when you max out your card. ")
            print("While you are at it never draw money from an ATM with a credit cards. Banks see this as a high risk short term loan and many banks will charge you daily intrest just for having the loan.")
            print("If you try and open more cards you may get denied or have you accounts closed you be careful.")
            print("If you want a travel card if I were you I would get the Barclays AA card")
            cards1 = ["Chase Freedom", "Chase Sapphire Reserve", "Chase Sapphire Preferred", "American Express Gold Card", "Capital One Venture Card"]
            print("Some other great cards to look at are:", *cards1, sep='\n')

            sw524Y = input("Do you want the Southwest Companion Pass?: ")
            if sw524Y == "Y":
                    print("You need to wait because as good as that pass is as a person who is over the 524 you aren't getting it any time soon.")
            if sw524Y == "N":
                print("You won't get it anyway. Good on you for knowing your limits. Give it time any you may get it one day.")
            if sw524Y != "Y" or "N":
                print("Please enter valid data next time.")
                    
            cashback()

        def cashback():
            cback = input("Do you want cash back? Enter Y or N. ")
            if cback == "Y":
                print("Okay. I would get either the Arrival+ or the Capital One Venture. Both come with great sign up bonuses. ")
            if cback == "N":
                print("Maybe you would like a travel card like the Chase Sapphire Preferred.")
            if cback != "Y" or "N":
                print("I guess you don't want any card. Okay then.")

        if rule524 == "N":
            print("Good for you. Now just because you opened under 5 credit cards in the last 24 months doesn't mean you can get any card you want")
            print("Different cards have different rewards so I'm going to need to ask you what options you value most.")
            print("Since you are under the 5/24 rule the recommended rate is 1 card every three months for the most benefits")
            print("There are a few great cards but to get the most benefits you should also be under the 4/24 rule or 4 cards in the last 24 months")
            cardnumber = input("How many cards did you open in the last 24 months?: ")
            if cardnumber <= 2:
                    print("You seem to be on the path to some great cards. You have a lot of flexibility.")
            if cardnumber >=2:
                    print("You have less flexibility but you still have the oportunity to open some great cards")
                    
            cards1 = ["Chase Freedom", "Chase Sapphire Reserve", "Chase Sapphire Preferred", "American Express Gold Card", "Capital One Venture Card"]
            print("While you wait I would look at some of these great cards for the future:", *cards1, sep='\n')
            

            rule424 = input("Have you opened 4 or more credit cards in the past 24 months? Please enter Y or N: ")
            if rule424 == "Y":
                ruleY2()

            def ruleY2():
                print("At least you haven't opened 5 or more cards in the last 24 months but you are essentialy in the same place as the person in the 5/25 category")
                print("You don't have the option of opening multiple cards in the span of a few months")
                print("I would get the Ink Preferred card")