Photo by Sven Brandsma on Unsplash
Reverse Prefix of Word
https://leetcode.com/problems/reverse-prefix-of-word
class Solution:
def reversePrefix(self, word: str, ch: str) -> str:
index = word.find(ch)
if index > -1:
first = word[:index + 1]
second = word[index + 1:]
return first[::-1] + second
else:
return word