Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String Manipulation Coding

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is String Manipulation Coding. Start with the requirements on the right.

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.

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):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output