Answer the question
In order to leave comments, you need to log in
How to invert values in python?
How do I invert a variable like variable x
?
x=o
x = not x
print(x)
x=True
def ain():
x = not x
print(x)
ain()
Answer the question
In order to leave comments, you need to log in
1. Pass a variable to the function
2. Return the result from the function
What could be simpler? Well, forget about the use of global variables, beginners do not know how to use them.
For example, like this:
x = True
def ain(_x):
_x = not _x
print(_x)
return _x
x = ain(x)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question