def List_Nats(n):
    '''
    Write a recursive function that takes as an input a positive integer and outputs list of natural numbers from 1 to that integer
    '''
    if n ==1:
        return  [1]
    else:
        return  List_Nats(n-1) + [n]


The key to this type of natural display is the "pre" type of element (which maintains the look as it is entered). 'View source' to see the HTML used to display this way and then copy and paste in your own editor to try it out (see the GIF to see how to do this):