0

Here's my code;

def save(name):
    if x['fname'] == 'ply.json':
        save1(name)
    elif x['fname'] not 'ply.json':
        write_data({'fname':'ply.json', 'name':'Karatepig'}, 'ply.json')

I get an error stating that I have this syntax error:

File "<stdin>", line 4
  elif x['fname'] not 'ply.json':
                               ^

What am I doing wrong?

Karatepig
  • 29
  • 7
  • 5
    This question should be closed because it is predicated on a typo and will have no utility for future readers. – jscs Dec 23 '13 at 02:20

3 Answers3

1

something not something is not a valid expression. If you want to test if it is not equal, use !=:

elif x['fname'] != 'ply.json':

However, since this is the exact opposite of the preceding if test, just use else here:

if x['fname'] == 'ply.json':
    save1(name)
else:
    write_data({'fname':'ply.json', 'name':'Karatepig'}, 'ply.json')
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

You need to use != to test inequality, like this:

    elif x['fname'] != 'ply.json':

But why use elif?

def save(name):
    if x['fname'] == 'ply.json':
        save1(name)
    else:
        write_data({'fname':'ply.json', 'name':'Karatepig'}, 'ply.json)
tckmn
  • 57,719
  • 27
  • 114
  • 156
0

You need to use != for "not equal":

elif x['fname'] != 'ply.json':
Community
  • 1
  • 1