To implement the concept of indexing and slicing in python3.
Every data type in python3 like list,tuple variables stores numbers, strings and characters.
Every element that starts with index 0.
Its starts with left to right with positive index number.
Its starts with right to left with negative index number.
Eg.
we can call multiple element in a list
or tuple or any other data type
in pythonby creating a range
of index numbers separated by
a colon [x:y]
#simple list and tuple data type
list1=[‘bala’,’naren’,’vivek’,’sathish’,10,45,85,20]
tuple1=(‘bala’,’naren’,’vivek’,’sathish’,10,45,85,20)
list2=[“banana”,”mango”,”jackfruit”]
print(“******Indexing examples******”)
#positive indexing
print(list1[0])
#negative indexing
print(tuple1[-1])
print(“******Slicing examples*******”)
#slicing
print(list1[0:6])
print(tuple1[2:5])