Итак, глядя на входные данные на вашем изображении, вот лучшее решение
sentences = []
while True:
word_list = input().split()
sentences = [*sentences, word_list]
if len(word_list) < 1:
break
Так что теперь, когда у вас есть входные данные из командной строки, вы можете сделать
[word.upper() if len(word)%2 == 1 else word.lower() for word_list in sentences for word in word_list]
илиВы можете извлечь в функцию
def apply_case(word):
if len(word)%2:
return word.upper()
return word.lower()
new_sentences = [apply_case(word) for word_list in sentences for word in word_list]
, теперь вы можете напечатать ее как
output = "\n".join([" ".join(word_list) for word_list in new_sentences])
print(output)