If the following code equates to ‘True’:
'1234567' in '1234567:AMC'
Why won’t the opposite also indicate ‘True’? They both share the 1234567 character strings.
'1234567:AMC' in '1234567'
Is there a way this get this to say ‘True’ for the line of code above?
>Solution :
The str type has a .find() method with can be used.
The method returns the starting position of the found string, or -1 if not found.
For example:
'1234567:AMC'.find('1234567')
Returns 0. Indicating the primary string contains the substring starting at index 0. If the substring was not found, -1 would be returned.