Best way to print 1 to n integer in python

I have an input n = 3.
so, i want a list with 1 to 3 integer.

Input:
3
Output:
[1,2,3]

Here is how i do this:

n = int(input())
c = []
for x in range(1,n+1):
    c.append(x)
print(c)

But,what if n = 100.Then i have to continue my loop in 100 times.Is there any short way which is more efficient ?

print(list(range(1, n + 1)))
print([i + 1 for i in range(0, n)])
1 Like