Skip to content

Commit 48eda6b

Browse files
Add files via upload
1 parent b27a359 commit 48eda6b

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

Diff for: Section_04/assignment_07.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,7 @@
1212
1313
"""
1414

15-
def string_match(a, b):
16-
17-
# Figure out which string is shorter
18-
shorter = min(len(a), len(b))
19-
20-
count = 0
21-
22-
for i in range(shorter - 1):
23-
a_sub = a[i: i+2] # gives us substring of size 2
24-
b_sub = b[i: i+2]
25-
if a_sub == b_sub:
26-
count = count + 1
27-
28-
return count
15+
#Your Code Below:
2916

3017

3118

Diff for: Section_04/assignment_08.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,22 @@
1414
1515
"""
1616

17-
def sum78(nums):
17+
#Your Code Below:
18+
19+
20+
21+
22+
23+
24+
25+
26+
1827

19-
sum = 0
20-
in_range = False
2128

22-
for i in range(len(nums)):
2329

24-
if nums[i] == 7:
25-
in_range = True
2630

27-
if in_range == False:
28-
# sum = sum + nums[i]
29-
sum += nums[i]
3031

31-
if nums[i] == 8:
32-
in_range = False
3332

34-
return sum
3533

3634

3735
print(sum78([1, 2, 2])) #→ 5

0 commit comments

Comments
 (0)