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
-
Why DELETE with Subqueries Fails in PySpark SQL (And How to Fix It)
Learn why PySpark SQL DELETE with WHERE IN subquery fails and how to fix it using DELETE USING, Delta tables, and join-based deletes.
-
GitHub Features & Settings Explained: The Ultimate GitHub Options Guide
GitHub options explained in detail. Explore GitHub features, settings, and best practices to manage repositories and workflows effectively.
-
Ingesting Data from AWS S3 into Databricks with Auto Loader: Building a Medallion Architecture
In this blog post, we will explore efficient methods for ingesting data from Amazon S3 into Databricks using Auto Loader. Additionally, we will discuss how to perform data transformations and implement a Medallion architecture to improve the management and processing of large datasets. What is the Medallion Architecture? The Medallion architecture is a data modeling…






