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

String Reversal Coding Task

EasyPython

Problem

Given a string sentence, write a program that reverses it.

Reverse every character, including spaces and punctuation, and return the resulting string. Implement the function reverse_sentence(sentence), which accepts one string and returns one string. An empty string is valid input.

Constraints

  • 0 <= len(sentence) <= 10^5
  • sentence may contain letters, digits, spaces, and punctuation
  • Return the characters in exact reverse order

Function Signature

def reverse_sentence(sentence):
Interviewer

Your question is String Reversal Coding Task. 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.