Return to Python after a two-year hiatus. Don't remember the best way to iterate over a string from the beginning and stop at a specific character and then return the string.
def my_string(long_string, char):
newstr = " "
for i in range(len(long_string)):
if long_string[i] == char:
# now what?
I know I need to create a new line and then run a loop to go through the existing line. But then I got stuck. I know that I need to return a new line, but I'm not sure what the rest of my code looks like. Thanks in advance for your help.
source
share