Python program to Fill a List with Natural Numbers

x = int(input("Insert range of natural numbers: "))
num = [y+1 for y in range(x)]
print(num)

 

 

 

Output:

Insert range of natural numbers: 8
[1, 2, 3, 4, 5, 6, 7, 8]

 

Insert range of natural numbers: 5
[1, 2, 3, 4, 5]

 

Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns