[Tutor] While problem
Jack Little
jacklittlemc at yahoo.com
Thu Jun 27 02:32:56 CEST 2013
I have a small problem with the while function.It prints an odd variable that has nothing to do with the function. It prints "Squad One!". Here is my code for the 3 def's that have something to do with the while function.
def tcombat():
c1am=10
c2am=10
enam="Qasi"
ehealth=15
edam=random.choice([5,6,7,8,9])
thealth=20
tdam=random.choice([6,7,8,9,10])
enemyalive=True
while enemyalive==True:
t2=raw_input(">>")
if t2.lower=="FIRE CANNON 1":
c1am-=c1am-1
ehealth-tdam
print "Cannon Fired!"
print "Enemy Health=", ehealth
elif t2.lower=="FIRE CANNON 2":
c2am=c2am-1
ehealth-tdam
print "Cannon Fired!"
print "Enemy Health=", ehealth
print "Good Job!"
print "You beat the training dummy."
print "Nothing like real combat"
print "But screw you, here you go!"
print "(Into real combat)"
lvl3()
def lvl2_2():
print "Squad Nine"
print "This team looks very....umm..Dumb."
print "There is one guy sitting on a stool"
print "he has a star sticker on his chest."
print "The other guy is vomiting on his"
print "pants."
print "BEGIN TRAINING"
print "TRAINING: When you are roaming around the skies, you type 'Engage [Ship Name]'"
print "TRAINING: While in combat, type 'Fire [Cannon Number (not spelt)]' to fire a cannon at a ship"
print "All entries must be in lower caps!"
print "TRAINING: There may be consequences for firing upon certain ships."
print "--BEGIN TRAINING--"
print "There is a ship near yours, the Qasi. It is flying"
print "the enemy flag."
print "There are 2 cannons on your ship."
c1am=10
c2am=10
enam="Qasi"
ehealth=15
edam=random.choice([5,6,7,8,9])
thealth=20
tdam=random.choice([6,7,8,9,10])
enemyalive=True
if ehealth==0:
enemyalive=False
t1=raw_input(">>")
if t1.lower=="engage qasi":
print enam ,"Engaged in Combat"
tcombat()
def lvl2_1():
print "Squad One"
print "This team looks much more able than Squad Nine."
print "TYRONE:Hi! I'm Tyrone, he's James, she's Ashley, and that guy over there,"
print "he's Bob."
print "BEGIN TRAINING"
print "TRAINING: When you are roaming around the skies, you type 'Engage [Ship Name]'"
print "TRAINING: While in combat, type 'Fire [Cannon Number (not spelt)]' to fire a cannon at a ship"
print "TRAINING: There may be consequences for firing upon certain ships."
print "--BEGIN TRAINING--"
print "There is a ship near yours, the Qasi. It is flying"
print "the enemy flag."
print "There are 2 cannons on your ship."
c1am=10
c2am=10
enam="Qasi"
ehealth=15
edam=random.choice([5,6,7,8,9])
thealth=20
tdam=random.choice([6,7,8,9,10])
enemyalive=True
if ehealth==0:
enemyalive=False
t1=raw_input(">>")
if t1.lower=="ENGAGE QASI":
print "Engaged in Combat"
tcombat()
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130626/357b5cc8/attachment.html>
More information about the Tutor
mailing list