Count nodes in Circular linked list

def get_length(self):
temp =self.head
count = 0
if temp == None:
return count
while(temp):
count +=1
temp = temp.next
if temp==self.head:
return count

--

--

Looking for my next opportunity to make change in a BIG way

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store