Here is a Python program that prints N numbers. It asks input from the user how many numbers to print. The user input is used in the if condition to print the numbers.
Here is sample Python program
nums= []
# number of elements as input
n = int(input("Enter number of elements : "))
# iterating till the range
for i in range(0, n):
ele = int(input("Enter number:"))
nums.append(ele) # adding the element
print(nums)
Also read: 12 Tricky Python Coding Interview Questions
The result of the program
Enter number of elements :
5
Enter number:
1
Enter number:
2
Enter number:
3
Enter number:
4
Enter number:
5
[1, 2, 3, 4, 5]
** Process exited - Return Code: 0 **
Press Enter to exit terminal
Related posts
-
JCL MSGCLASS Vs. MSGLEVEL Top Differences
The MSGCLASS and MSGLEVEL control the print of messages to the output listing. Here are the detailed meanings and default values.
-
20 Software Engineer Gift Ideas: From Gadgets to Games
Here are the top gift ideas for software developers that you can buy online for their marriages, birthdays, and other special occasions.
-
Web 3.0 Key Properties that Improve User Satisfaction
Here are the essential properties of Web 3.0 and how it helps the user improve web usage satisfaction.