Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: invalid syntax
#5
Thank you I think it worked. I have other bugs that popped up so I can't check it out right now

I have another question for myPlayer_job, I want to know if this is a valid statement (if not, how would I write it?)

##### Class Stats #####
if myPlayer.job == 'warrior' == 'mighty warrior':
    player_hp = 100                                     #What I want to do here is, when the player wants to choose his "job" in "Job Handling"
    player_mp = 20                                      #let's say he wants to be a "warrior". If the player were to input "mighty warrior" it would
elif myPlayer.job == 'wizard' == 'mighty wizzard':      #still give him the same class.
    player_hp = 50                                      #First of all, the "if myPlayer.job == 'warrior' == ' mighty warrior':" probably wont work.
    player_mp = 120                                     #If I were to type "print(myPlayer.job)" this would probably give an error.

### Job Handling
question3 = "Well then, tell me...\n Are you a mighty Warrior or a wize Wizard?\n"
    player_job = input('> ')
    valid.jobs = ['warrior', 'wizard']
    if player_job.lower() in valid.jobs:
        myPlayer.job = player_job                                            
    else:
        while player_job.lower not in valid.jobs:
            print('Say again, I did not understand.')
            print('What are you? a Warrior or a Wizard?')
            player_job = input('> ')
            if player_job.lower() in valid.jobs:
                myPlayer.job = player_job
As I'm writing this, I got another bug.
The code below gives the following error:
'a1': {
TypeError: unhashable type: 'dict'

I don't understand what part in the code is an immutable object

ZONENAME = 'zonename'
DESCRIPTION = 'description'
EXAMINATION = 'examination'
SOLVED: False
UP = 'up'
DOWN = 'down'
LEFT = 'left'
RIGHT = 'right'

zonemap = {
    'a1': {
        ZONENAME: 'Desert',
        DESCRIPTION: 'description',
        EXAMINATION: 'examination',
        SOLVED: False,
        UP: '',
        DOWN: 'b1',
        LEFT: '',
        RIGHT:'a2',
    },
    'a1': {
        ZONENAME: 'Desert',
        DESCRIPTION: 'description',
        EXAMINATION: 'examination',
        SOLVED: False,
        UP: '',
        DOWN: 'b1',
        LEFT: '',
        RIGHT:'a2'
    }
}
Reply


Messages In This Thread
SyntaxError: invalid syntax - by Kanashi - Nov-22-2019, 10:58 PM
RE: SyntaxError: invalid syntax - by ichabod801 - Nov-22-2019, 11:02 PM
RE: SyntaxError: invalid syntax - by Kanashi - Nov-22-2019, 11:35 PM
RE: SyntaxError: invalid syntax - by ichabod801 - Nov-22-2019, 11:50 PM
RE: SyntaxError: invalid syntax - by Kanashi - Nov-23-2019, 04:48 AM
RE: SyntaxError: invalid syntax - by ichabod801 - Nov-23-2019, 03:13 PM
RE: SyntaxError: invalid syntax - by ichabod801 - Nov-23-2019, 03:27 PM
RE: SyntaxError: invalid syntax - by Kanashi - Nov-24-2019, 05:59 AM
RE: SyntaxError: invalid syntax - by ichabod801 - Nov-24-2019, 01:39 PM
RE: SyntaxError: invalid syntax - by Kanashi - Nov-24-2019, 08:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print(data) is suddenly invalid syntax db042190 6 3,624 Jun-14-2023, 02:55 PM
Last Post: deanhystad
  SyntaxError: invalid syntax ?? korenron 15 10,229 Jan-25-2022, 11:46 AM
Last Post: korenron
  Invalid syntax with an f-string Mark17 7 17,119 Jan-14-2022, 04:44 PM
Last Post: Mark17
  invalid syntax in my class CompleteNewb 2 3,462 Dec-13-2021, 09:39 AM
Last Post: Larz60+
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 4,440 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Unexplained Invalid syntax Error cybertooth 5 5,764 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  [split] SyntaxError: invalid syntax Code_X 3 3,886 May-04-2021, 05:15 PM
Last Post: Yoriz
  Invalid syntax error - need help fixing calgk01 3 4,679 Feb-23-2021, 08:41 PM
Last Post: nilamo
  Invalid syntax using conditionals if - else jperezqu 1 3,059 Jan-13-2021, 07:32 PM
Last Post: bowlofred
  invalid syntax in line 5. Help Asadzangibaloch 2 3,330 Dec-10-2020, 04:26 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020