Skip to content

Commit cf6c6d2

Browse files
authored
Merge pull request B3ns44d#1 from programandoconro/programandoconro
Changed 'remove' for 'del' method and fixed typos in Merge_Sort.py
2 parents 377ca18 + ed992c1 commit cf6c6d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Merge_Sort.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def merge_sort(unsorted_list):
22
if len(unsorted_list) <= 1:
33
return unsorted_list
4-
# Find the middle point and devide it
4+
# Find the middle point and divide the unsorted list
55
middle = len(unsorted_list) // 2
66
left_list = unsorted_list[:middle]
77
right_list = unsorted_list[middle:]
@@ -18,16 +18,16 @@ def merge(left_half,right_half):
1818
while len(left_half) != 0 and len(right_half) != 0:
1919
if left_half[0] < right_half[0]:
2020
res.append(left_half[0])
21-
left_half.remove(left_half[0])
21+
del left_half[0]
2222
else:
2323
res.append(right_half[0])
24-
right_half.remove(right_half[0])
24+
del right_half[0]
2525
if len(left_half) == 0:
2626
res = res + right_half
2727
else:
2828
res = res + left_half
2929
return res
30-
# you can add any list of number here
30+
# You can add any list of numbers here
3131
unsorted_list = [6,5,3,1,8,7,2,4]
3232

3333
print(merge_sort(unsorted_list))

0 commit comments

Comments
 (0)