Skip to content

Commit 8bf380c

Browse files
cclaussgithub-actions
and
github-actions
authored
README.md: sumab() --> sum_ab() for consistancy (TheAlgorithms#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>
1 parent c775baf commit 8bf380c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ We want your work to be readable by others; therefore, we encourage you to note
8282
```python
8383
def sum_ab(a, b):
8484
"""
85-
Returns the sum of two integers a and b
85+
Return the sum of two integers a and b
8686
>>> sum_ab(2, 2)
8787
4
8888
>>> sum_ab(-2, 3)
@@ -116,8 +116,8 @@ We want your work to be readable by others; therefore, we encourage you to note
116116
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission.
117117

118118
```python
119-
def sumab(a: int, b: int) --> int:
120-
pass
119+
def sum_ab(a: int, b: int) --> int:
120+
return a + b
121121
```
122122

123123
- [__List comprehensions and generators__](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions) are preferred over the use of `lambda`, `map`, `filter`, `reduce` but the important thing is to demonstrate the power of Python in code that is easy to read and maintain.

data_structures/linked_list/middle_element_of_linked_list.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ class LinkedList:
88
def __init__(self):
99
self.head = None
1010

11-
def push(self, new_data:int) -> int:
12-
new_node = Node(new_data)
13-
new_node.next = self.head
11+
def push(self, new_data: int) -> int:
12+
new_node = Node(new_data)
13+
new_node.next = self.head
1414
self.head = new_node
1515
return self.head.data
1616

1717
def middle_element(self) -> int:
18-
'''
18+
"""
1919
>>> link = LinkedList()
2020
>>> link.middle_element()
2121
No element found.
@@ -44,11 +44,11 @@ def middle_element(self) -> int:
4444
>>> link.middle_element()
4545
12
4646
>>>
47-
'''
47+
"""
4848
slow_pointer = self.head
4949
fast_pointer = self.head
50-
if self.head:
51-
while fast_pointer and fast_pointer.next:
50+
if self.head:
51+
while fast_pointer and fast_pointer.next:
5252
fast_pointer = fast_pointer.next.next
5353
slow_pointer = slow_pointer.next
5454
return slow_pointer.data

0 commit comments

Comments
 (0)