Thursday, October 23, 2025
HomeLanguagesPython program to print list elements in different ways

Python program to print list elements in different ways

Python program to print list elements in different ways; In this tutorial, you will learn how to print list elements in different ways in python.

Python program to print list elements in different ways

There are some ways to print list elements in python program:

  • 1: Python Print List Elements using For Loop
  • 2: Python program to print list without using loop
  • 3: Python program to print list using map

1: Python Print List Elements using For Loop

# Python program to print list using for loop 

# define a list
a = [1, 2, 3, 4, 5] 
  
# printing the list using loop 
for x in range(len(a)): 
     print(a[x])

After executing the program, the output will be:

1
2
3
4
5

2: Python program to print list without using loop

# Python program to print list without using loop 
  
a = [1, 2, 3, 4, 5] 
  
# printing the list using * operator separated  
# by space  
print(*a) 
  
# printing the list using * and sep operator 
print("printing lists separated by commas") 
  
print(*a, sep = ", ")  
  
# print in new line 
print("printing lists in new line") 
  
print(*a, sep = "\n") 

After executing the program, the output will be:

1
2
3
4
5

3: Python program to print list using map

# Python program to print list using map
  
a = [1, 2, 3, 4, 5] 
print(' '.join(map(str, a)))  
  
print("in new line")
print('\n'.join(map(str, a))) 

After executing the program, the output will be:

1 2 3 4 5
in new line
1
2
3
4
5

Recommended Python List Programs

  1. How to Input List From User in Python
  2. Python: Add/Insert Element at Specified Index in List
  3. Python Program to Remove ith/Nth Occurrence of Given Word in List
  4. Python Program to Sort List in Ascending and Descending Order
  5. Python to Find the Differences of Two Lists
  6. Python to Find Minimum and Maximum Elements of List
  7. Python Programs to Split Even and Odd Numbers in Separate List
  8. Python Program to Create Two Lists with First Half and Second Half Elements of Given List
  9. Python Program to Swap Two Elements in a List
  10. Python Program to Reverse List
  11. How To Select Random Item From A List In Python
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS