[Facebook data engineer coding] Write a function that, given a string representing a sentence, returns the sentence with the words in the same order but the letter in each word reversed.

Data Science Interview QuestionsCategory: Data Engineer Coding[Facebook data engineer coding] Write a function that, given a string representing a sentence, returns the sentence with the words in the same order but the letter in each word reversed.
1 Answers
MockInterview Staff answered 2 months ago

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 #1] Start learning through a free trial on Datacamp!
[Content Sponsor #2] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!

Your Answer

15 + 18 =

Data Science Career Bootcamp