---
title: "How to Print N numbers in a List in Python"
description: "Here is a Python logic that prints N numbers as per user input. Useful for interviews and written tests"
url: https://srinimf.com/2022/03/27/how-to-print-n-numbers-in-a-list-in-python/
date: 2022-03-27
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2022/03/pexels-photo-4476376.jpeg?fit=1880%2C1253&ssl=1
categories: ["Python"]
tags: ["python programs"]
type: post
lang: en
---

# How to Print N numbers in a List in Python

Here is a Python program that prints N numbers. It asks input from the user how many numbers [to print](https://srinimf.com/2023/06/05/how-to-print-sum-of-prime-numbers-in-python/). The user input is used in the if condition to print the numbers.

Related[Python Interview Prep in 1 Hour: 12 Essential Coding Programs](https://srinimf.com/2025/09/10/python-interview-prep-in-1-hour-12-essential-coding-programs/)

Related[How to Measure Speed of Python Code](https://srinimf.com/2022/07/11/how-to-measure-speed-of-python-code/)

## 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)
```

Related[The Amazing Fact Why Can’t We use Loops in Python Lambda](https://srinimf.com/2022/05/30/amazing-fact-why-cant-we-use-for-in-python-lambda/)

**Also read: **[12 Tricky Python Coding Interview Questions](https://srinimf.com/2020/02/23/12-frequently-asked-python-interview-questions/)

Related[5 Nice Ways to Convert String to Matrix: Python](https://srinimf.com/2024/05/31/5-nice-ways-to-convert-string-to-matrix-python/)

## 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

- [How to Print Name[String] in Reverse order in Python](https://srinimf.com/2021/11/20/python-program-to-print-name-in-reverse-order/)DateNovember 20, 2021
- [Python Interview Prep in 1 Hour: 12 Essential Coding Programs](https://srinimf.com/2025/09/10/python-interview-prep-in-1-hour-12-essential-coding-programs/)DateSeptember 10, 2025
- [12 Tricky Python Coding Interview Questions](https://srinimf.com/2020/02/23/12-frequently-asked-python-interview-questions/)DateFebruary 23, 2020

- [![30 SQL Practice Queries with Solutions — Run Them Live](https://i0.wp.com/srinimf.com/wp-content/uploads/2026/10/pexels-photo-5530473.jpeg?resize=867%2C1300&ssl=1)](https://srinimf.com/2026/10/01/30-sql-practice-queries-with-solutions-run-them-live/) ## [30 SQL Practice Queries with Solutions — Run Them Live](https://srinimf.com/2026/10/01/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!](https://i0.wp.com/srinimf.com/wp-content/uploads/2026/09/pexels-photo-1181469.jpeg?resize=1880%2C1255&ssl=1)](https://srinimf.com/2026/09/30/supercharge-your-database-skills-try-our-new-interactive-sql-plugin/) ## [Supercharge Your Database Skills: Try Our New Interactive SQL Plugin!](https://srinimf.com/2026/09/30/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](https://i0.wp.com/srinimf.com/wp-content/uploads/2026/09/pexels-photo-14314638.jpeg?resize=1880%2C1253&ssl=1)](https://srinimf.com/2026/09/27/how-to-count-spark-stages-by-sight-and-optimize-shuffles/) ## [How to Count Spark Stages by Sight and Optimize Shuffles](https://srinimf.com/2026/09/27/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.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2022%2F03%2F27%2Fhow-to-print-n-numbers-in-a-list-in-python%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2022%2F03%2Fpexels-photo-4476376.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=How%20to%20Print%20N%20numbers%20in%20a%20List%20in%20Python)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2022/03/27/how-to-print-n-numbers-in-a-list-in-python/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2022/03/27/how-to-print-n-numbers-in-a-list-in-python/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2022/03/27/how-to-print-n-numbers-in-a-list-in-python/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2022/03/27/how-to-print-n-numbers-in-a-list-in-python/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Print%20N%20numbers%20in%20a%20List%20in%20Python&body=https%3A%2F%2Fsrinimf.com%2F2022%2F03%2F27%2Fhow-to-print-n-numbers-in-a-list-in-python%2F&share=email)
-

### Like this:

Like Loading…
