python - Convert an integer to its negative -
i'm trying write code if occurence happens, specific number has change -that number. have following code far:
x=6 words in foo: if "bar" in words: crazy_function(x) else: pass
if word "bar" in words, x need come out -6, if not in words, needs come out +6. in cases x=-6 in case needs become positive if bar in words. need replace "crazy_function()" works.
use negation operator:
x=6 words in foo: if "bar" in words: x = -x;
Comments
Post a Comment