'End of statement expected' pyCharm error

Asked

Viewed 43 times

1

I have a very simple method, which takes a Boolean parameter and changes a global one to the negated value of the parameter. However, using the Pycharm IDE, it returns an error in the snippet global state = not x

state = False

def change_state(x):
    global state = not x

erros que aparecem no pycharm

What does this error mean? What would be the correct form of the code?

1 answer

3


The problem is that the assignment of the value of the global variable is on the same line.

The right thing would be:

state = False

def change_state(x):
    global state
    state = not x
    print(state)

change_state(state)

Upshot:

True

Browser other questions tagged

You are not signed in. Login or sign up in order to post.