Remove .md and image files and move python files into main chapter folders
This commit is contained in:
parent
5978779a9a
commit
67806dab6a
159 changed files with 0 additions and 4562 deletions
27
thinkcspy/Chapter-9-Exercises/Problem11.py
Normal file
27
thinkcspy/Chapter-9-Exercises/Problem11.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 9
|
||||
# Problem 11
|
||||
|
||||
def remove(substr,theStr):
|
||||
# your code here
|
||||
pos1 = 0
|
||||
pos2 = len(substr)
|
||||
found = False
|
||||
newStr = theStr
|
||||
|
||||
while pos1 < len(newStr) and not found:
|
||||
currentPos = newStr[pos1:pos2]
|
||||
|
||||
if substr == currentPos:
|
||||
newStr = newStr[:pos1] + newStr[pos2:]
|
||||
found = True
|
||||
else:
|
||||
pos1 += 1
|
||||
pos2 += 1
|
||||
|
||||
return newStr
|
||||
|
||||
print(remove("e", "tree"))
|
||||
print(remove("iss", "Mississippi"))
|
||||
print(remove("an", "banana"))
|
||||
print(remove("e", "treeeleee"))
|
||||
Loading…
Reference in a new issue