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
-
30 SQL Practice Queries with Solutions — Run Them Live
Practice 30 SQL queries with solutions, from SELECT and JOINs to subqueries and window functions. Run SQL queries live in an interactive SQL Playground.
-
Supercharge Your Database Skills: Try Our New Interactive SQL Plugin!
Struggling with database queries? Explore our new interactive SQL plugin to write, test, and master SQL directly in your browser. Try the live demo now!
-
How to Count Spark Stages by Sight and Optimize Shuffles
Want to predict execution stages before running a job? Learn how to count Spark stages by sight with code breakdowns, shuffle rules, and optimization traps.



