THE CHALLENGESTRING_POSITION — The first position of a string (without POS).
Without using the built-in POS function, read two strings ch1 and ch2 and find the first position (1 for the start) of ch1 in ch2.
Input:
pas
compas
Output:
La position de pas dans compas est : 4
"Home-made POS" challenge: no find(), no index() - compare slices ch2[i:i+len(ch1)] in ONE loop.
Checks (verified automatically before your code runs):
- Do not use find().
- Do not use index().
- At least 1 slice like s[a:b].
- At most 1 loop in the whole program (for, while and comprehensions all count).