Ad
Fundamentals

this is not the best code to do this task beacause i have used while loops to make it more understandable

if [4] is input then your code should return [1234321], your code should count up and then down, and then return an int, not a string.

Code
Diff
  • def numberprint(x):
        nor = 0
        final = ''
        while nor < x:
            nor += 1
            final += str(nor)
        while nor > 1:
            nor -= 1
            final += str(nor)
        return int(final)
    • def numberprint(x):
    • accending = list(range(1, x + 1))
    • descending = list(range(x-1, 0, -1))
    • newlist = accending + descending
    • strings = [str(integer) for integer in newlist]
    • a_string = "".join(strings)
    • an_integer = int(a_string)
    • return an_integer
    • nor = 0
    • final = ''
    • while nor < x:
    • nor += 1
    • final += str(nor)
    • while nor > 1:
    • nor -= 1
    • final += str(nor)
    • return int(final)