Answer:
def printIndexed(s):
for i in range(len(s)):
print(s[i] + str(len(s) - 1 - i), end="")
printIndexed("ZELDA")
Step-by-step explanation:
*The code is in Python.
Create a method named printIndexed that takes one parameter, s
Create a for loop that iterates the length of the s times
Inside the loop, print the characters from starting and indexes from the end
Note that in order the print the current character, you need to use indexing. s[i] refers to the current character of the string (the value of the i starts from 0 and goes until length of the s - 1). Also, to print the indexes from the end, you need to subtract the i from the length of the s - 1
For example, in the first iteration, i = 0:
s[i] = s[0] = Z
len(s) - 1 - i = 5 - 1 - 0 = 4