In this program – we are going to learn how can we print all list elements, print specific elements, print a range of the elements, print list multiple times (using * operator), print multiple lists by concatenating them, etc.
Syntax to print list in different ways:
print (list) # printing complete list
print (list[i]) # printing ith element of list
print (list[i], list[j]) # printing ith and jth elements
print (list[i:j]) # printing elements from ith index to jth index
print (list[i:]) # printing all elements from ith index
print (list * 2) # printing list two times
print (list1 + list2) # printing concatenated list1 & list2
Python code to print list elements
Here, we have two lists list1 and list2 with some of the elements (integers and strings), we are printing elements in the different ways.
Output
need an explanation for this answer? contact us directly to get an explanation for this answer