DEV Community

Cover image for Squared Numbers Function
Scott Gordon
Scott Gordon

Posted on

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)