[Tutor] Newbie Project part 2...
Tony Noyeaux
tnoyeaux at msn.com
Sat Jul 14 15:57:06 CEST 2007
Thanks to all the tutors,... your advice has been invaluable todate,.. the learning continues.
The code below..asks the user to pick one of 3 options,.. once they choose,... a random result happens based on their choice.
---------------------------------------------------------
import randomprint "\t\t\t\tLife Simulator"print "You have just turned 18 years old. Your life awaits,... choices to be made.."print "\na)Army,\nb)Navy,\nc)Airforce"job=raw_input("What will u join?")
if job == "a": print random.choice(["You win Silver star", "You are killed in action"])elif job == "b": print random.choice(["You fall overboard", "You command you're own battleship"])elif job == "c": print random.choice(["You get shot down", "You become wing commander"])
raw_input("\n\nPress Enter to quit.")----------------------------------------------------------------------
This works fine.
I am having trouble coding in the 2nd question,.. and all subsequent questions.
The next Question.. has to be a result of the random result.
So, if they choose .. b).. and they join the navy,... random result,..."you command battleship results"... then,... a specific question,... with, and abc responce,.. will trigger. Obviosly,. there will be alot of responces to all the different options stored. Just trying to get the framework working which i have not been able to sucessfully accomplish yet.
So for the sake of the example, the user chose B)Navy ---> You command battleship random resulted... Then this question appeared. "Will you reenlist for another four years"? random results of "You are Promoted to Secretary of the Navy", "You lose a leg in a torpedo attack".
All the actual responces and random results are just examples to get the structure and code working.
I am hoping to be able to print a summary of each happening ... as results are generated. So the user can see their own personal story build.. based on their responces etc.
Thanks again for the insights you've given todate.
Tony Noyeaux
_________________________________________________________________
Local listings, incredible imagery, and driving directions - all in one place! Find it!
http://maps.live.com/?wip=69&FORM=MGAC01
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070714/31c64f06/attachment.htm
More information about the Tutor
mailing list