Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
String Manipulation Coding
00:00
5 left

String Manipulation Coding

EasyPython

Problem

Stonex Group displays short text labels whose words occasionally need character-level reversal for a formatting operation. Given a string, reverse the characters in every word while preserving the original word order and the single spaces between words.

Formal Specification

Implement reverse_words(text).

  • Input: text, a non-empty string containing one or more words separated by exactly one space.
  • Output: A string with each individual word reversed. The number and positions of spaces must remain unchanged.
  • Words contain printable non-space characters. Do not reverse the order of the words.

Constraints

  • 1 <= len(text) <= 10^4
  • text contains no leading or trailing spaces
  • Words are separated by exactly one space
  • The input contains at least one word

Function Signature

def reverse_words(text):
Interviewer

Your question is String Manipulation Coding. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.