#class 2
#List Operatin in Python
doting_list = [int(x) for x in input("Enter list values with 1, 111, 112: ").split()]  #taking list input 
print ("Original list: ", doting_list)


# append() is used to add element at the end of the list
doting_list.append(4)  
print ("Append 4: ", doting_list)


""" extends the list by appending all the items from the iterable. 
    Iterable can be a List, Tuple or a Set."""
doting_list.extend([6,7,8]) 
print ("Extend list: ", doting_list)


""" insert(pos, element) is used to inserts
    the specified value at the specified position"""
doting_list.insert(3, 12)
print ("Insert item at index 3: ", doting_list)


""" remove(item) method removes the first occurrence 
    of the element with the specified value"""

doting_list.remove(1)
print ("Remove 1 from the list: ", doting_list)

""" pop(item index_no) method return the deleted value """
doting_list2=doting_list.pop(2)
print ("Pop Element: ",doting_list2)

"reverse list "
doting_list.reverse()
print ("Reverse list: ", doting_list)

"length of list"
print("list length: ",len(doting_list))
print("Maximum of the list", max(doting_list))
print ("Minimum of the list: ", min(doting_list))
print ("Sortin the list: ", sorted(doting_list))
print ("Count element: ", doting_list.count(4))
print ("Print the index value of the element: ", doting_list.index(4))
print ("Multiply lilst: ", 3*doting_list)
copy_dotinglist = doting_list.copy()
print (copy_dotinglist)
print("clear the  copy_dotinglist: ", copy_dotinglist.clear())


"""Slicing the list - List[Initial : Ena : IndexJump]"""
print("Main list: ", doting_list)

Sliced_list = doting_list [2: :2]
print("Sliced list: ", Sliced_list)

Sliced_list= doting_list[::]   # will show whole list, if leave 
print("Show whole list using slice: ", Sliced_list)

Sliced_list = doting_list[-5: : 2]
print("Sliced using negative index: ", Sliced_list)

Sliced_list = doting_list[::2]  #Slice list using 2 jump
print("Slice 2 Jump: ", Sliced_list)

"""A reversed list can be generated by using a negative integer as the IndexJump argument.
Leaving the Initial and End as blank.
We need to choose the Initial and End value according to
 a reversed list if the IndexJump value is negative. """
Sliced_list = doting_list[::-3]  
print("Slice -3 Jump: ", Sliced_list)

"""If some slicing expressions are made that do not make
 sense or are incomputable then empty lists are generated."""
Error_list = doting_list[:0:]
Error_list2 = doting_list[-1:-1:-1]
print("Error list: {} {}".format(Error_list, Error_list2))

""" List slicing can be used to modify lists or even delete elements from a list."""
print ("list Editing : ", doting_list[:3]+doting_list[7:])
print ("list Editing : " , doting_list[::2] + doting_list[::-3])



#Pass by Reference 
print("For pass         :", doting_list)
new_list = doting_list
doting_list.remove(111)
print("We remove 111 from the doting_list and it also removed from the new_list: ")
print ("Pass by reference:", new_list)
# Pass by Value 
new_list2 = doting_list.copy()
doting_list.remove(112)
print("We remove 112 from the doting_list but it doesn't remove from the new_list2: ")
print("Pass by value    :", new_list2)