statement= "I am a python developer" for word in statement.split(" "): if len(word) >= 5: statement = statement.replace(word, word[::-1]) print(statement)
u do understand that this solution is incomplete right ? you are simply taking the words >=5 and reversing them , but the final answer have to be in the same order of the initial statement as a string with just the words >=5 reversed.
statement= "I am a python developer"
for word in statement.split(" "):
if len(word) >= 5:
statement = statement.replace(word, word[::-1])
print(statement)
Thanks
" ".join([word for word in statement[::-1].split(" ") if len(word) >= 5])
Thanks
u do understand that this solution is incomplete right ? you are simply taking the words >=5 and reversing them , but the final answer have to be in the same order of the initial statement as a string with just the words >=5 reversed.
output = " ".join([stat[::-1] if len(stat)>=5 else stat for stat in statement.split(' ')])
Thanks