python 打印列表元素
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