Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program To Print List Elements In Different Methods


This example shows, how to print list elements in different methods in using python.

Here's the example:
Example.py
a = ["Ram", "Sam", "Saraa", 30, 23, 17]
b = [50, 100, "Welcome", "All"]

print (a)               # Print complete a
print (a[0])            # Print first element of a
print (a[0], a[1])    # Print first & second elements
print (a[2:5])          # Print elements from 2nd to 5th index
print (a[1:])           # Print all elements from 1st index
print (b * 2)          # Print b two times
print (a + b)         # Print concatenated a & b

Output

['Ram', 'Sam', 'Saraa', 30, 23, 17]
Ram
Ram Sam
['Saraa', 30, 23]
['Sam', 'Saraa', 30, 23, 17]
[50, 100, 'Welcome', 'All', 50, 100, 'Welcome', 'All']
['Ram', 'Sam', 'Saraa', 30, 23, 17, 50, 100, 'Welcome', 'All']

Prev Next