You can use list comprehensions for this problem as it will solve it in only two lines.
Code-
n = int(input("Enter the range of the list:\n"))
l1 = [i for i in range(n)] #Creates list of numbers in the range 0 to n
if __name__ == "__main__":
print(l1)