String of Numbers

Write a function called string_of_numbers that receives an integer length
and uses a while loop to create and return a string of consecutive numbers from 1 up to the number length.


>>>  string_of_numbers(3)

>>>  string_of_numbers(5)

You'll need variables to store your result string and a number keeping track of what loop your on.
You might need to use the str() function to change an integer into a string at some point.

Important: We've recorded a video with the solution of this exercise, in case you get stuck:

Test Cases

test 3 nums long - Run Test

def test_3_nums_long():
    assert string_of_numbers(3) == "123"

test 5 nums long - Run Test

def test_5_nums_long():
    assert string_of_numbers(5) == "12345"

Solution 1

def string_of_numbers(length):
    number_string = ""
    count = 1
    while count <= length:
        number_string += str(count)
        count += 1
    return number_string
def string_of_numbers(length): pass