I took a few coding classes in college and am trying to relearn the skills I have lost. The program I am attempting to write takes a string and returns that string backwards: "Nope" becomes "epoN" for example. I was just wondering if you could help me figure out exactly what is wrong in my logic or syntax!
EDIT: Thanks everyone. I fixed the problem by making the variable lengthOfWord = len(string)- 1
ALSO I'm sorry I didn't post my error message. I forgot that rule and will do it in the future. Thanks again!
def ReverseString(string):
finalWord = ""
lengthOfWord = len(string)
while lengthOfWord >= 0:
finalWord = finalWord + string[lengthOfWord]
lengthOfWord = lengthOfWord - 1
else:
print(finalWord)
return