employer cover photo
employer logo

Sollicitatievraag bij VMware

Write a program to reverse a string

Antwoord op sollicitatievraag

Anoniem

3 nov 2020

the easy answer is reversed(string). If they want you to manually do the replacing yourself, something like this works def reverse_string(string: str)-> str: i = 0 j = len(string) - 1 # index based string = list(string) while i < j: string[i], string[j] = string[j], string[i] i += 1 j -= 1 return ''.join(string)