Ad
Fundamentals

Done using two list comprehensions.

Code
Diff
  • def numberprint(x):
        return int("".join([str(i) for i in range(1,x)]+[str(i) for i in range (x,0,-1)]))
        
    
    • 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)
    • return int("".join([str(i) for i in range(1,x)]+[str(i) for i in range (x,0,-1)]))