Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python inconsistent use of spaces and tabs problem

fh1

Active Coder
Hello! Im having a problem with my quiz code. Its showing an error on line 42 saying there is a inconsistent use of tabs and spaces. I tried just using space but it still did not work, i even tried rewriting the line again but it still says it.
Python:
points = 3
inventory = []
pointMultiplier = 2
shop = "Shop: point multiplier is 2 points. type it to get it"
print("Press E to stop playing at any time. And press S to visit the shop.")
while True:
    print("A. 50")
    print("B. 23")
    print("C. 63")
    question1 = input("How many states are there?")
    if question1 == "a" or question1 == "A":
        print("Correct!")
        points += 1
        break
    elif question1 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question1 not in ["a", "A", "B", "b", "C", "c", "E", "e", "s", "S"]:
        print("Wrong input!")
        continue
    elif question1 == "s" or question1 == "S":
        shop1 = input(shop)
        if shop1 == "Point Multiplier":
            if points > pointMultiplier or points == pointMultiplier:
                print("Bought")
                inventory.append(shop1)
                points -= 2
                print(f"you know have {points} point(s)")
            else:
                print("dont have enough :(")
                continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. 632")
    print("B. 43")
    print("C. 365")
    question2 = input("How many days does it take for the Earth or orbit the Sun?")
    if question2 == "C" or question2 == "c":
        print("Correct!")
        have = input("Do you have a Point Multiplier?")
        if have == "Yes":
            if shop1 not in inventory:
                print("you dont have it!")
            else:
                wannaUse = input("You have it! do you want to use it?")
                if wannaUse == "Yes":
                    points += 2
        points += 1
        break
    elif question2 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question2 not in ["a", "A", "B", "b", "C", "c", "E", "e"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Pablo Piccasso")
    print("B. Leanorda Da Vinci")
    print("C. Walt Disney")
    question3 = input("Who painted the Mona Lisa?")
    if question3 == "b" or question3 == "B":
        print("Correct!")
        points += 1
        break
    elif question3 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question3 not in ["a", "A", "B", "b", "C", "c", "E", "e"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again")
        continue
while True:
    print("A. Omnivours")
    print("B. Carnivours")
    print("C. Dinosaur")
    question4 = input("What are animals that eat both meat and plants called?")
    if question4 == "A" or question4 == "a":
        print("Correct!")
        points += 1
        break
    elif question4 == "E" or question4 == "e":
        print(f"Points: {points}")
        quit()
    elif question4 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Pneumonia")
    print("B. Acrophobia")
    print("C. Neophobia")
    question5 = input("What is the fear of heights called?")
    if question5 == "B" or question5 == "b":
        print("Correct!")
        points += 1
        break
    elif question5 == "e" or question5 == "E":
        print(f"Points: {points}")
        quit()
    elif question5 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Aerophobia")
    print("B. Astraphobia")
    print("C. Neophobia")
    question6 = input("What is the fear of flying called?")
    if question6 == "A" or question6 == "a":
        print("Correct!")
        points += 1
        break
    elif question6 == "e" or question6 == "E":
        print(f"Points: {points}")
        quit()
    elif question6 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
            print("Wrong input!")
            continue
    else:
        print("Wrong! Try again.")
        continue
i know its lots of code
 
Hello! Im having a problem with my quiz code. Its showing an error on line 42 saying there is a inconsistent use of tabs and spaces. I tried just using space but it still did not work, i even tried rewriting the line again but it still says it.
Python:
points = 3
inventory = []
pointMultiplier = 2
shop = "Shop: point multiplier is 2 points. type it to get it"
print("Press E to stop playing at any time. And press S to visit the shop.")
while True:
    print("A. 50")
    print("B. 23")
    print("C. 63")
    question1 = input("How many states are there?")
    if question1 == "a" or question1 == "A":
        print("Correct!")
        points += 1
        break
    elif question1 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question1 not in ["a", "A", "B", "b", "C", "c", "E", "e", "s", "S"]:
        print("Wrong input!")
        continue
    elif question1 == "s" or question1 == "S":
        shop1 = input(shop)
        if shop1 == "Point Multiplier":
            if points > pointMultiplier or points == pointMultiplier:
                print("Bought")
                inventory.append(shop1)
                points -= 2
                print(f"you know have {points} point(s)")
            else:
                print("dont have enough :(")
                continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. 632")
    print("B. 43")
    print("C. 365")
    question2 = input("How many days does it take for the Earth or orbit the Sun?")
    if question2 == "C" or question2 == "c":
        print("Correct!")
        have = input("Do you have a Point Multiplier?")
        if have == "Yes":
            if shop1 not in inventory:
                print("you dont have it!")
            else:
                wannaUse = input("You have it! do you want to use it?")
                if wannaUse == "Yes":
                    points += 2
        points += 1
        break
    elif question2 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question2 not in ["a", "A", "B", "b", "C", "c", "E", "e"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Pablo Piccasso")
    print("B. Leanorda Da Vinci")
    print("C. Walt Disney")
    question3 = input("Who painted the Mona Lisa?")
    if question3 == "b" or question3 == "B":
        print("Correct!")
        points += 1
        break
    elif question3 == "e" or question1 == "E":
        print(f"Your points: {points}")
        quit()
    elif question3 not in ["a", "A", "B", "b", "C", "c", "E", "e"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again")
        continue
while True:
    print("A. Omnivours")
    print("B. Carnivours")
    print("C. Dinosaur")
    question4 = input("What are animals that eat both meat and plants called?")
    if question4 == "A" or question4 == "a":
        print("Correct!")
        points += 1
        break
    elif question4 == "E" or question4 == "e":
        print(f"Points: {points}")
        quit()
    elif question4 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Pneumonia")
    print("B. Acrophobia")
    print("C. Neophobia")
    question5 = input("What is the fear of heights called?")
    if question5 == "B" or question5 == "b":
        print("Correct!")
        points += 1
        break
    elif question5 == "e" or question5 == "E":
        print(f"Points: {points}")
        quit()
    elif question5 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
        print("Wrong input!")
        continue
    else:
        print("Wrong! Try again.")
        continue
while True:
    print("A. Aerophobia")
    print("B. Astraphobia")
    print("C. Neophobia")
    question6 = input("What is the fear of flying called?")
    if question6 == "A" or question6 == "a":
        print("Correct!")
        points += 1
        break
    elif question6 == "e" or question6 == "E":
        print(f"Points: {points}")
        quit()
    elif question6 not in ["A", "a", "B", "b", "c", "C", "e", "E"]:
            print("Wrong input!")
            continue
    else:
        print("Wrong! Try again.")
        continue
i know its lots of code
Hi there,
I ran your code with an online complier and it runs just fine. Are you running it on Windows or Linux/mac?
 
hi! im running it on my ipad
Hey there,
So I ran your code on both my windows command prompt and my ubuntu WSL and both seem to work just fine. For the sake of just doing so, delete all the space before your code on line 42, and hit tab twice.. then try to run
 
Not sure what editor you use to write the code, but doesn't it have an option like 'Show visible spaces' so that you can see where there might be a TAB where a space should be ?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom