Python - How to print python list elements?
Published May 13, 2021In this python programming example we will learn how to print list elements, print Nth index element, list range elements, add two list elements. We have default python list properties to do all these list operations.
Syntax:
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 Nth index
print (list[i:]) # printing all elements from ith index
print (list * 2) # printing list two times
print (listOne + listTwo) # printing concatenated listOne & listTwo
Print List items in Python Example
listInt = [1, 24, 92, 221, 212, 137] print (listInt) |
Explanation: In the above example we have two lists listInt and list2.
To print list elements we will print (listInt) method
To print Nth index elements will use print (listInt[0]) method, we will pass index number to the list method
Output for above example
[1, 24, 92, 221, 212, 137] |
Related
Python remove last character from string
Article Contributed By :
|
|
|
|
473 Views |