Oct-02-2021, 01:03 PM
(Oct-01-2021, 07:44 PM)deanhystad Wrote: When the PEP talks about multiple statements on one line it means code like this:
squares = []; cubes = [] for x in range(10): squares.append(x**2); cubes.append(x**3) print(squares); print(cubes)Each line has multiple expressions. The PEP is not condemning list comprehensions or a conditional expressions/ternary operators. A list comprehension is a single statement. Maybe a complex looking statement, but still a single statement/expression. Once you get comfortable using them you'll find yourself seeking opportunities to use them.
Oh I didnt talk about the list comprehension, the first thing.
But it doesnt matter, I prefer less doing list comprehension, maybe in the future when I will get better at python.
Thanks :)