Python Forum
Unknown output - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Unknown output (/thread-3773.html)



Unknown output - brzo - Jun-22-2017

So I recently acquired this book "Adventures in Python" by Craig Richardson and I instantly dived into the book as an introduction in the python coding language. It all was a walk in the park until I reached this part. I type all the code down but I keep being stuck in here.

choice = ""
while choice != "/exit":
print "What would you like to do, " + captain + "?"
print ""
print "a. Explore another planet?"
print "b. Fire your Cannons?"
print "c. Open the airlock?"
print "d. Self destruct (ANY RISK IS NOT THE RESPONSIBILITY OF AIRSPACE INDUSTRIES!"
print ""
choice = raw_input ("Enter your choice: ")
The elif's are there thus the program has to obey but yet it doesn't, the output doesn't work. Here is an example of the elif outputs.

if choice == "a":
destination = raw_input("Where would you like to go? ")
print "leaving " + location
print "Travelling to " + destination
time.sleep(5)
print "Arrived at " + destination
location = destination

I will always be stuck on the letter option part even if I type a letter. Hopefully I can have this fixed as quick as possible.


RE: Unknown output - ichabod801 - Jun-22-2017

There is not enough here to help you out. First of all, use python tags (see the BBCode tutorial link in my signature). Second, there's not enough code here to diagnose anything. You need to give us enough code to find the problem, but not too much. Try to trim code to isolate the problem, and show us that. Then describe exactly what input you're giving it, what output you're getting, and why it's wrong.


RE: Unknown output - brzo - Jun-24-2017

Sorry about the inconvenience, ichabod801, I fixed the problem by rewriting the entire code. My problem was that I spaced out certain sectors of the code for aesthetic use which entirely botched up my code.


RE: Unknown output - Larz60+ - Jun-24-2017

Please share your fix with other users.