You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ We want your work to be readable by others; therefore, we encourage you to note
56
56
57
57
```python
58
58
"""
59
-
This function sums a and b
59
+
This function sums a and b
60
60
"""
61
61
def sum(a, b):
62
62
return a + b
@@ -82,13 +82,13 @@ We want your work to be readable by others; therefore, we encourage you to note
82
82
The following "testing" approaches are **not** encouraged:
83
83
84
84
```python
85
-
input('Enter your input:')
85
+
input('Enter your input:')
86
86
# Or even worse...
87
-
input = eval(raw_input("Enter your input: "))
87
+
input = eval(input("Enter your input: "))
88
88
```
89
-
89
+
90
90
However, if your code uses __input()__ then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding __.strip()__ to the end as in:
91
-
91
+
92
92
```python
93
93
starting_value = int(input("Please enter a starting value: ").strip())
94
94
```
@@ -99,13 +99,13 @@ We want your work to be readable by others; therefore, we encourage you to note
99
99
def sumab(a, b):
100
100
return a + b
101
101
# Write tests this way:
102
-
print(sumab(1,2)) # 1+2 = 3
103
-
print(sumab(6,4)) # 6+4 = 10
102
+
print(sumab(1,2)) # 1+2 = 3
103
+
print(sumab(6,4)) # 6+4 = 10
104
104
# Or this way:
105
-
print("1 + 2 = ", sumab(1,2)) # 1+2 = 3
106
-
print("6 + 4 = ", sumab(6,4)) # 6+4 = 10
105
+
print("1 + 2 = ", sumab(1,2)) # 1+2 = 3
106
+
print("6 + 4 = ", sumab(6,4)) # 6+4 = 10
107
107
```
108
-
108
+
109
109
Better yet, if you know how to write [__doctests__](https://docs.python.org/3/library/doctest.html), please consider adding them.
110
110
111
111
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
Copy file name to clipboardExpand all lines: data_structures/linked_list/doubly_linked_list.py
+13-14
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,13 @@
4
4
- Each link references the next link and the previous one.
5
5
- A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.
6
6
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficent'''
7
-
from __future__ importprint_function
8
7
9
8
10
9
classLinkedList: #making main class named linked list
11
10
def__init__(self):
12
11
self.head=None
13
12
self.tail=None
14
-
13
+
15
14
definsertHead(self, x):
16
15
newLink=Link(x) #Create a new link with a value attached to it
17
16
if(self.isEmpty() ==True): #Set the first element added to be the tail
0 commit comments