DEV Community

Cover image for Squared Numbers Function
Scott Gordon
Scott Gordon

Posted on

2 1

Squared Numbers Function

# squared_number_function.py
#   This program uses a function to square each entry in a numbers list.
# by: Scott Gordon

def main():

    numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    squared_numbers = []

    def square_each(numbers):
        """This program uses a function to square each entry in a numbers list."""
        for number in numbers:
            squared_numbers.append(number ** 2)
        return squared_numbers

    print(square_each(numbers))


main()

Enter fullscreen mode Exit fullscreen mode

Photo by Volkan Olmez on Unsplash

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay