Kelimelere ayıralım ve sonuncu space ‘i düşünelim :)
Merhaba ,
Aşağıdaki code ile verilen string içinde, belli bir harften büyük bir harf ile başlayan kelimeleri bulabilirsiniz. Sonuncu space ‘ten sonraki kelime için .rfind( ) metodu kullanılabilir. Onu kullanmadan bulmaya çalıştım.
input_phrase = "Wheresoever you go, go with all your heart" word = "" start = 0 space_index = input_phrase.find(" ") for i in input_phrase: if i.isalpha(): word = word + i if space_index != -1: start = space_index + 1 space_index = input_phrase.find(" ", space_index + 1) elif word.lower() >= "h": print(word.upper()) word = "" else: word = "" print(input_phrase[start:].upper())