Skip to content

Commit

Permalink
Bug027 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JadSark committed Dec 14, 2023
1 parent 637cd09 commit eb64ecf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/BUG/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def replace_substring(s: str, old_sub: str, new_sub: str) -> str:
"""
BUG027: replace_substring should replace occurrences of old_sub with new_sub, not append new_sub.
"""
result = s + new_sub
result = s
index=result.find(old_sub)
while index != -1:
result= result[:index] + new_sub + result[index+len(old_sub):]
index=result.find(old_sub)
return result


Expand Down

0 comments on commit eb64ecf

Please sign in to comment.