I am new to python and I am trying to use different methods to accomplish the same task. Now I am trying to figure out how to get a substring from a string using for loopand while loop, I quickly found that it is a very simple task to accomplish regex. For example, if I have a line: "ABCDEFGHIJKLMNOP" and I want to find out if "CDE" exists and then print "CDE" + the rest of the line, how can I do this with loops? Now I am using:
for i, c in enumerate(myString):
which returns every index and character, which I believe is the beginning, but I cannot figure out what to do after. I also know that there are many built-in functions for finding substrings by executing: myString. (Function), but I still would like to know if it is possible to do this using loops.
source
share