ARTICLEViews: 9Share  Posted by - Anonymous

write a python program to reverse statment words as following

// input = "my name is user name"

// output = "name user is name my"


statment = "my name is user name"


def reverseStatement(st):

 word_indx = 0

 reverse_st = ""

 for i, char in enumerate(st):

if char.isspace() or i == len(st) -1:

word_end = i if i == len(st) -1 else i -1

 

  word = st[word_indx: word_end+1]

reverse_st = word + " " + revervse_st

word_indx = i + 1

return reverse_st



Topic : How To Reverse Words in a String ######################### Udemy Courses: ...

Python Program To Reverse The Each Word Of String

Python || Q5. Write a Program To REVERSE internal content of each word?

How to Find Reverse a String in Python ? #shorts

Python Program To Reverse The Words of String



Views -