I want to turn the following for loop: into a one liner. I figured I could do something like this: but I need to update the value of x0 in each instance of the loop. Any ideas? Answer Walrus operator := to the rescue:
Tag: one-liner
One liner for True or False for loop in Python
Almost every time I solve an exercise of Codewars and glance at others solutions I see that some guys do my 15 lines code in 2 or 3 lines. So, I have started to learn lists and sets comprehensions and would try other tricks. For now my question is about this code: Is it possible to write it in one