I have to make this program track how much fuel I have used. I have tried and tried, but I can't get it to work... I'm not at all looking for a solution... I just need a nudge/hint into the right direction.
def main():
choice = 0
ammo = 5
fuel = 200
while choice != 4 and ammo != 0:
print "Menu Selections:"
print "1 - Fire Weapon"
print "2 - Move Forward"
print "3 - Move Backward"
print "4 - Exit"
choice = input("Enter Your Selection ==> ")
if choice == 1:
fireWeapon()
ammo = ammo - 1
if ammo == 0:
print "You are out of ammo!"
else:
print "You have",ammo,"shots left"
elif choice == 2:
moveForward(fuel)
elif choice == 3:
moveBackward(fuel)
elif choice == 4:
print "Goodbye!"
else:
print "Invalid Input! Try Again."
def fireWeapon():
distance = input("How far away is your target?")
if distance <= 20:
print "Target destroyed!"
elif distance < 40:
print "The target is partially disabled"
else:
print "Target is unharmed"
def moveForward(fuel):
path = input("How many feet would you like to move backward?")
obstacle = input("How many feet away is your nearest obstacle?")
if path - obstacle == path:
print "You have moved forward",path,"feet."
if path - obstacle < path:
distance = path - obstacle
print "Your path is blocked. You can only move",path,"feet"
def moveBackward(fuel):
path = input("How many feet would you like to move backward?")
obstacle = input("How many feet away is your nearest obstacle?")
if path - obstacle == path:
print "You have moved forward",path,"feet."
if path - obstacle < path:
distance = path - obstacle
print "Your path is blocked. You can only move",path,"feet"
main()