Python Python Basics All Together Now Gather Information

Ammar Mazhar
Ammar Mazhar
438 Points

The code won't run

For some reason every time I try to run my code by calling the file to run " python masterticket.py" the code won't run and the cursor starts a new line without any error notifications. How may I fix that problem ?

5 Answers

Steven Parker
Steven Parker
186,321 Points

If you get no errors, it's quite likely that the code did run, but it did not produce any output before it finished.

If you'd like us to be able to check for certain, make a snapshot of your workspace and post the link to it here.

Steven Parker
Steven Parker
186,321 Points

I made a fork (working copy) of your snapshot, and it seemed to work as expected:

treehouse:~/workspace$ python masterticket.py
There are 100 tickets remaining.
What is your name?Joe
How many tickets would you like, Joe?     4
The total due is $42
Do you want to proceed Y/N  y
SOLD!
There are 96 tickets remaining.      
What is your name?scalper
How many tickets would you like, scalper?     96
The total due is $962
Do you want to proceed Y/N  y
SOLD!
Sorry the tickets are all sold out!!:(
treehouse:~/workspace$

Looking at the code, I noticed that the indentation on lines 17-20 was not consistent with the rest of the program, but it did not seem to cause an issue.

Kathy Kinsella
Kathy Kinsella
1,306 Points

I am running the masterticket.py program and even though I tell it to thank them by name at the sale, the code does not do this. what am I doing wrong? here is my snapshot https://w.trhou.se/bofrjcof1q

Kathy Kinsella
Kathy Kinsella
1,306 Points

How is it that it is doing one thing for you and something different with you? It's not confirming the name

Kathy Kinsella
Kathy Kinsella
1,306 Points

I see that it is confirming the name but it is not thanking them by name. I thought this script was supposed to thank the buyer by name

Steven Parker
Steven Parker
186,321 Points

The line "print("Thank you anyways, {}!".format(name))" is only used when the user does not proceed after being told the price. I didn't select that option in the example, but it does work also.

Kathy Kinsella
Kathy Kinsella
1,306 Points

OH, I didn't understand that. But yep it does work. thanks for the help

Steven Parker
Steven Parker
186,321 Points

Kathy Kinsella — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!