+ 6

Python - Why doesn't --a raise an error, but neither change "a" value?

a = 5 b = 7 if not a != b - 2: print("a =",a) print("b =",b) b = --a print("a =",a) print(a + b)

26th Sep 2019, 12:28 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
2 Antworten
+ 4
It is just a double negation : - - a = - 1 * -1 * a So the only thing u r doing is setting b=a.
26th Sep 2019, 12:47 PM
Thoq!
Thoq! - avatar
+ 4
I understand now! Thank you!
26th Sep 2019, 1:13 PM
Paolo De Nictolis
Paolo De Nictolis - avatar