Assignment 1 commit: Moon & Apollo

This commit is contained in:
Brockmann
2025-10-25 15:25:29 +02:00
commit bf74311add
15 changed files with 257 additions and 0 deletions
View File
+21
View File
@@ -0,0 +1,21 @@
def substring(string: str, start: int, end: int = 0) -> str:
"""
A substring function
:param string: The string
:param start: The starting index
:param end: The ending index. If None, this is set to the length of the substring :return:
"""
if not isinstance(string, str):
raise ValueError("No string provided")
if not isinstance(start, int):
raise ValueError("No starting index provided")
if end is None:
end = len(str)
result = ""
for i in range(start, end):
result += string[i]
return result