I tried coming up with a way to do a reverse string function without using the [ : : -1] method. I'm new to coding and am trying to only use the "primitive" steps. Below is my function and specifications. I was wondering if this is an efficient way to write the function. I appreciate any help. Thanks!
def reverse(word):
x = -2 #word in reversed order counter
y = 1 #starts counter to end "while" statement below
reversed = word[-1] #starts the reversed-word at last letter of word
while len(word) > y: #ending parameter for when all letters run through loop
reversed += word[x] #adds letters to reversed word starting at word[-2]
x -= 1 #moves position in word 1 to the left
y += 1 #increases the counter by 1
return reversed