Let's test your knowledge. Click the correct answer from the options.

What will the following pseudocode do to an input string?

1def reverse_str(str):
2  start = 0
3  end = len(str)-1
4  str_copy = [letter for letter in str]
5  while start < end:
6    temp = str_copy[start]
7    str_copy[start] = str_copy[end]
8    str_copy[end] = temp
9    start += 1
10    end -= 1
11  return "".join(str_copy)

Click the option that best answers the question.

  • Make a copy
  • Reverse the string
  • Swap the first and last letters
  • Infinite loop
OUTPUT
Results will appear here.