Very clever on zooming the code, that was a great detail Question: Is it recomended to use this comprehension? i mean it kinda affects readability but, what are good uses for it?
Great question! You should use list comprehensions when you want to quickly loop through or generate a list with minimal conditional statements. You should avoid using it when you have multiple conditions. It will make troubleshooting and readability more difficult with too many conditions.
Nice explanation! Trully useful for adding some extra spice to my projects. Keep up the good work buddy!
Thank you! :)
Loved the presentation ... very clear.
Also could use :
itemArr = [ f'item{n}' for n in range(3) ] to avoid the str cast
Python will still cast n to a string. Just implicitly.
Correct me if I'm worong
Very clever on zooming the code, that was a great detail
Question: Is it recomended to use this comprehension? i mean it kinda affects readability but, what are good uses for it?
Great question! You should use list comprehensions when you want to quickly loop through or generate a list with minimal conditional statements. You should avoid using it when you have multiple conditions. It will make troubleshooting and readability more difficult with too many conditions.
perhaps we can also use append function as i.append("new") for i in itemList)
Absolutely! :)
Also, list comprehensions are faster!
which version of py
I use Python 3.11.8