A
Alexnb
Okay, I have a fix for this problem, but it is messy and I think there might
be a better way. Heres an example:
Lets say I have a string: "My name is alex"
and I have another string "My name is alex, and I like pie".
I want to test to see if just the "My name is alex" part is there. I don't
care about the pie part.
My first instinct was to just create a for loop and test for the string like
this:
n = 0
for x in string1:
if string1[n] == string2[n]
n = n +0
else:
break
and then later testing to see what n was = to and figuring out if it got
through the whole loop. I feel like there should be an easier way to do
this, and probably is. So Does anyone have a suggestion?
be a better way. Heres an example:
Lets say I have a string: "My name is alex"
and I have another string "My name is alex, and I like pie".
I want to test to see if just the "My name is alex" part is there. I don't
care about the pie part.
My first instinct was to just create a for loop and test for the string like
this:
n = 0
for x in string1:
if string1[n] == string2[n]
n = n +0
else:
break
and then later testing to see what n was = to and figuring out if it got
through the whole loop. I feel like there should be an easier way to do
this, and probably is. So Does anyone have a suggestion?