Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

Python Program to print Elements in a List

by suresh

In this article, we will show you, How to write a Python Program to print Elements in a List with practical example. Before you start, please refer List article to understand everything about Lists.

Python Program to print Elements in a List Example 1

The print function in python will automatically print elements in a List

# Python Program to print Elements in a List 

a = [10, 50, 60, 80, 20, 15]

print("Element in this List are : ")
print(a)

OUTPUT

Python Program to print Elements in a List 1

Python Program to print Elements in a List Example 2

This python program is same as above but this time we are using For Loop to iterate each every element in a list, and printing that element. This is very useful to alter the individual item using this index position.

# Python Program to print Elements in a List 

a = [10, 50, 60, 80, 20, 15]

print("Element in this List are : ")
for i in range(len(a)):
    print("Element at Position %d = %d" %(i, a[i]))

OUTPUT

Python Program to print Elements in a List 2

Python Program to print List Elements Example 3

The print function in python also print string elements in a List

# Python Program to print Elements in a List 

Fruits = ['Apple', 'Orange', 'Grape', 'Banana']

print("Element in this List are : ")
print(Fruits)

OUTPUT

Python Program to print Elements in a List 3

Python Program to print List Elements Example 4

This is same as above but we used For Loop to iterate each every string element in a list.

# Python Program to print Elements in a List 

Fruits = ['Apple', 'Orange', 'Grape', 'Banana']

print("Element in this List are : ")
for fruit in Fruits:
    print(fruit)

OUTPUT

Python Program to print Elements in a List 4

Python Program to print List Elements Example 5

This program allow user to enter any integer value. This is the length of a List. Next, we used For Loop to add numbers to the list.

# Python Program to print Elements in a List 

NumList = []
Number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, Number + 1):
    value = int(input("Please enter the Value of %d Element : " %i))
    NumList.append(value)

for i in range(Number):
    print("The Element at index position %d = %d " %(i, NumList[i]))

OUTPUT

Python Program to print Elements in a List 5

Placed Under: Python, Python Examples

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy