Python3 List Examples

1. Simple Example To Show How To Create A List In Python3.


a=['a','b','c','d','e',1,2,3,4,5,6,7,8]
b=[1,2,3,4,5,6,7,8]

print(a)
print(b)

2. Simple Example To Show Functions Of List In Python3.


a=['a','b','c','d','e',1,2,3,4,5,6,7,8]
b=[1,2,3,4,5,6,7,8]
del a[1] # del for deleting values from list at specified index 
print(a)
print(b*3)
print(b[4])
print(len(b))

3. Simple Example To Show Insert and Remove Functions Of List In Python3.


a=['a','b','c','d','e',1,2,3,4,5,6,7,8]
b=[1,2,3,4,5,6,7,8]

b[5]=10
b.insert(6,10)
print(b)
b.remove(10)
print(b)

4. Simple Example To Show How To Convert List Into Stack In Python3.

b=[1,2,3,4,5,6,7,8]


for i in b:
    print(i)

print(b)
b.append(9)
b.append(10)
print(b)
b.pop()
b.pop()
print(b)
 

5. Simple Example To Show Use Of Negative Indexing Using List In Python3.

 a=['a','b','c','d','e',1,2,3,4,5,6,7,8]
b=[1,2,3,4,5,6,7,8]

print(a[-1])
print(b[-1])