Construct a function that calculates the number of elements in a singly linked list.
LinkedList class implementation is given below.
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def push(self, new):
new_node = Node(new)
new_node.next = self.head
self.head = new_node