On 11/21/2016 07:10 PM, rmjbr...@gmail.com wrote:
Hi! This is my first post! I'm having trouble understanding my code. I get 
"SyntaxError:invalid syntax" on line 49. I'm trying to code a simple text-based 
rpg on repl.it. Thank you for reading.



print("Welcome to Gladiator Game! Choose your character race, class, and starting 
equipment!")

print('')

print("Race selection: ")

print('')

print("(1) Orcs. Known for their very wide, robust physiques. They are the strongest 
of all the races in Polaris.")

print('')

print("(2) Elves. Thin and wiry. They are known for their amazing agility and 
hand-eye coordiation. They originate from the desert island of Angolia.")

print('')

print("(3) Silverbacks. A hairy, ape-like race from Nothern Polaris. Their metal fur 
provides them with much needed protection.")

print('')

print("(4) Pomongos. An amphibian race believed to inhabit the wet jungles of 
Central Polaris. Legends say they have highly corrosive spit...")

print('')

raceNum=int(input("Select your character's race by entering the corresponding 
number. Then press enter: "))

print('')

while raceNum<1 or raceNum>4:
  raceNum=int(input('Invalid input. Try again: '))

print('')

if raceNum==1:
  print("You're an orc, eh? I won't be sayin' anything mean about you...")
  print('')
  classNum=int(input("What's your profession big fella?"))

elif raceNum==2:
  print("I never liked you elven folk...Let's get on with this.")
  print('')
  classNum=int(input("What's your profession ? Do ye even have one ?"))

elif raceNum==3:
  print("Nice fur. I don't see too many of your kind 'round here. Maybe that's a 
good thing...")
  print('')
  classNum=int(input("What's your profession mate?")

elif raceNum==4:             #this line has an error for some reason
  print("Your a 'Mongo eh? I thought you lads were extinct...Just keep your tongue 
in ya mouth and we'll get along fine mate.")
  classNum=int(input("What's your profession?"))


You've already received answers about your typo so I won't repeat that. However I have a couple minor suggestions about your approach.

First, the empty string in your print('') statements is unnecessary. Just use print(), it does the same thing.

Next your menu for the raceNum selection is straight-forward, and there is nothing wrong with that. But another approach that might be a bit shorter is to use a list of strings displayed in a loop. Something like this (very simplified) example...

<code>
options = ['First option',
    'Next option',
    'One more time',
    #  etc........
    ]
#  This version assumes the option number is part of the strings
for opt in options:
    print(opt)
    print()    #  If you really want the double-spacing, personally I don't 
think it's needed
</code>

Here's a bit more advanced version of the for loop, this one assumnes the option numbers are not in the strings in the list...

<code>
for num, opt in enumerate(options, 1):
    print('({})  {}'.format(num, opt))    #  OR   print('(%d)  %s' % (num, opt))
    print()    #  Again, double-spacing is optional
<code>

A similar approach could be used for your classNum section.

Just some suggestions to read/study/adapt...  or ignore.  Whatever you feel 
like.  ;-)

--
     -=- Larry -=-
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to