Sample run:
“I love programming” –> “I evol gnimmargrop”
[Content Sponsor] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!
3 Answers
def rev_string(phrase):
phrase_lst = phrase.split(‘ ‘)
rev_phrase = ”
for p in phrase_lst:
rev_phrase += p[::-1] + ‘ ‘
return rev_phrase.strip()
rev_string(“I love programming”)
[Content Sponsor] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!
def reversewordsnotsentence(sentence) : words =sentence.split() newsen=[] for word in words: word=word[::-1] newsen.append(word) return \” \”.join(newsen)
[Content Sponsor] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!
def reversewordsnotsentence(sentence) :
words =sentence.split()
newli=[]
for word in words:
word=word[::-1]
newli.append(word)
return ” “.join(newli)
print(reversewordsnotsentence( “the cattle was rattled by the battery”))
[Content Sponsor] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!
Your Answer