take note of the convention being used the point at which we append new nodes is through self head the self tail variable points to the first node in the list getting the size of the list we would like to be able to get the size of the list by counting the number of nodes one way we could do this is by traversing the entire list and increasing counter as we go alongdef size(self)count current self tail while currentcount + current current next return count this worksbut list traversal is potentially an expensive operation that we should avoid when we can so insteadwe shall opt for another rewrite of the method we add size member to the singlylinkedlist classinitializing it to in the constructor then we increment size by one in the append methodclass singlylinkedlistdef __init__(self)self size def append(selfdata)self size + because we are now only reading the size attribute of the node objectand not using loop to count the number of nodes in the listwe get to reduce the worst case running time from (nto (