README.md: sumab() --> sum_ab() for consistancy (#1855)

* README.md: sumab() --> sum_ab() for consistancy  

consistency

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2020-04-12 17:18:30 +02:00
committed by GitHub
parent c775baf55f
commit 8bf380ce7d
2 changed files with 10 additions and 10 deletions

View File

@ -8,14 +8,14 @@ class LinkedList:
def __init__(self):
self.head = None
def push(self, new_data:int) -> int:
new_node = Node(new_data)
new_node.next = self.head
def push(self, new_data: int) -> int:
new_node = Node(new_data)
new_node.next = self.head
self.head = new_node
return self.head.data
def middle_element(self) -> int:
'''
"""
>>> link = LinkedList()
>>> link.middle_element()
No element found.
@ -44,11 +44,11 @@ class LinkedList:
>>> link.middle_element()
12
>>>
'''
"""
slow_pointer = self.head
fast_pointer = self.head
if self.head:
while fast_pointer and fast_pointer.next:
if self.head:
while fast_pointer and fast_pointer.next:
fast_pointer = fast_pointer.next.next
slow_pointer = slow_pointer.next
return slow_pointer.data