I\'d like to remove all characters before a designated character or set of characters (for example):
intro = \"<>I\'m Tom.\"
Now I\'d
str.find
could find character index of certain string's first appearance
:
intro[intro.find('I'):]
I looped through the string and passed the index.
intro_list = []
intro = "<>I'm Tom."
for i in range(len(intro)):
if intro[i] == '<' or intro[i] == '>':
pass
else:
intro_list.append(intro[i])
intro = ''.join(intro_list)
print(intro)
Since index(char)
gets you the first index of the character, you can simply do string[index(char):]
.
For example, in this case index("I") = 2
, and intro[2:] = "I'm Tom."