Created
December 9, 2024 22:25
-
-
Save copocaneta/b9718dad9257385bfb9701af1554731e to your computer and use it in GitHub Desktop.
Improve this code by reducing verbosity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculating squares of even numbers with an imperative loop | |
numbers = [1, 2, 3, 4, 5] | |
even_squares = [] | |
for n in numbers: | |
if n % 2 == 0: | |
square = n * n | |
even_squares.append(square) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment