×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Program to input, append and print the list elements

Here, we are going to learn how to declare a list, input elements, append the elements in the list and finally, print the list? By IncludeHelp Last updated : June 22, 2023

Read the value of N (limit of the list), input N elements and print the elements in Python.

Example:

Input:
Enter limit of the list: 5
Enter an integer: 10
Enter an integer: 20
Enter an integer: 30
Enter an integer: 40
Enter an integer: 50

Output:
Input list elements are:
10
20
30
40
50

Program:

# declare a list
list = []

# read limit (value of n)
# for maximum number of elements
n = int(input("Enter limit of the list: "))

# input n integer element
# and append to the list
for i in range(n):
    item = int(input("Enter an integer: "))
    list.append(item)

# print all elements
print("Input list elements are: ")
for i in range(n):
    print(list[i])

Output

Enter limit of the list: 5
Enter an integer: 10
Enter an integer: 20
Enter an integer: 30
Enter an integer: 40
Enter an integer: 50
Input list elements are: 
10
20
30
40
50

Learn more about the lists: Python List Tutorial

Python List Programs »



Related Programs

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.