I have searched for a solution to this question among the existing answers on stackoverflow and have not been able to resolve my problem.
I want to iterate through the string "quote" and store each word in a placeholder variable word, print the word if the first letter is greater than or equal to h, and at a space move onto the next word.
However my loop seems to stop before iterating through the last word. Could someone help me understand why?
quote = "Wheresoever you go, go with all your heart"
word = ""
for letter in quote:
if letter.isalpha() == True:
word = word + letter
else:
if word.lower() >= "h":
print(word.upper())
word = ""
else:
word = ""
The output I get is:
WHERESOEVER
YOU
WITH
YOUR
The ouput I am trying to get is:
WHERESOEVER
YOU
WITH
YOUR
HEART