DEV Community 👩‍💻👨‍💻

Cover image for Strings to Numbers Function
Scott Gordon
Scott Gordon

Posted on

Strings to Numbers Function

# stings_to_numbers_function.py
#   This program converts a list of strings which are numbers and converts
#   them to numbers.
# by: Scott Gordon

def main():
    string_numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
    numbers = []

    def to_numbers(array):
        """Takes a list of string numbers and converts them to integers."""
        for item in array:
            numbers.append(int(item))
        return numbers

    print(to_numbers(string_numbers))


main()
Enter fullscreen mode Exit fullscreen mode

Photo by Chris Ried on Unsplash

Top comments (0)

Now it's your turn.

 
Join DEV and share your story.