Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unknown output
#1
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.
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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.
Reply
#4
Please share your fix with other users.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unknown characters in output using to_html Kishore01 2 1,905 Mar-20-2020, 10:20 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020