0

Is there any great example of code to explain the python's operator ":=" stregth?

The link shows here:https://docs.python.org/3/whatsnew/3.8.html

25th Sep 2020, 5:28 AM
RainStorm
RainStorm - avatar
1 Odpowiedź
+ 4
Both samples do the same thing, in the first one the operator is used. The same code is one line shorter. These are the samples: a = [1, 2, 3, 4, 5, 6, 7, 1, 3, 5, 5, 3, 4] if (n := len(a)) > 10: print(n) b = [1, 2, 3, 4, 6, 7, 1, 3, 5, 5, 3, 4] m = len(b) if (m > 10): print(m)
26th Sep 2020, 1:09 PM
Paul
Paul - avatar