Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now Handle Exceptions

How do i rectify this error

TabError: inconsistent use of tabs and spaces in indentation

2 Answers

I have tried it.. Its not working

Josh Keenan
Josh Keenan
19,528 Points

you need to do ``` and then you put your code, delete it and repaste it inside them, I can't help you because I can't see where you have gone wrong with the indent, read the markdown guide to help

Josh Keenan
Josh Keenan
19,528 Points

This means you have misindented your code somewhere, remember indentation matters too, if you need help debugging the code feel free to post it here and I can help.

Thank you.. I have pasted my code below:

TICKET_PRICE = 10

tickets_remaining = 100 while tickets_remaining >= 1: print("There are {} tickets remaining.".format(tickets_remaining)) name = input("What is your name? ") num_of_tickets = input("How many tickets would you like, {}? ".format(name)) try: num_of_tickets = int(num_of_tickets) if num_of_tickets > tickets_remaing: raise ValueError("There are only {} tickets reamining".format(tickets_remaining)

except ValueError as per err:
    print("Oh no, we have run into and issue. {}. Please try again".format(err)
else:     
    amount_due = num_of_tickets * TICKET_PRICE        
    print("The total due is ${}".format(amount_due) 
    prompt = input("Do you want to proceed?Y/N    ")    
    if prompt.lower() == "y":
        print("SOLD!!!")        
        tickets_remaining -= num_of_tickets
    else:
        print("Thank you anyways, {}!".format(name))

print("Sorry the tickets have all been sold out!!!! :(")

Josh Keenan
Josh Keenan
19,528 Points

Can you copy this ``` and paste it at the start and end of your code on another line, so it will format correctly.

your code here