Oh... this code looks fairly um, interesting. There are a number of things that should be changed.
It would be best to indent the lines 2- 57 in one level so that they're under the
if that triggers if the input is 1 - 4.
The problem that this should also solve is the "elif choice == 5: break". The issue is that because you put lines 46-56 in that same level as those "choice"
ifs, the breaking conditional is now linked as an elif for the "if gold >= price" statement.
Your code should be something like:
# ...
try:
choice = int(raw_input('Enter Number: '))
except ValueError:
print 'Invalid Input! Please input only numbers.\n'
if choice in [1, 2, 3, 4]:
global price
global ship
# I indented this below
if choice == 1:
ship = 'Sloop'
price = 1500
elif choice == 2:
ship = 'Schooner'
price = 3500
elif choice == 3:
ship = 'Brigantine'
price = 6500
elif choice == 4:
ship = 'Galley'
price = 9500
if gold >= price:
print 'You bought a new ship!'
gold -= price
print 'You now have:',
print gold,
print 'Gold\n'
elif gold < price:
print 'You do not have enough Gold!'
print 'Try again later!\n'
# ...all the way to here.
elif choice == 5:
break
elif links the statement to the most recent
if statement on the same level of indentation as it. All that part that I indented only happens if the choice is 1 - 4 anyways, so it should go under that
if choice in [1,2,3,4] statement.
The "break" part is now linked as an
elif to the
if choice in [1,2,3,4] statement because it is the most recent
if statement of the same indentation level.