我正在编写一个函数来反转一个字符串,但直到最后才完成它.我在这里错过了什么吗?
def reverse_string(str):
straight=list(str)
reverse=[]
for i in straight:
reverse.append(straight.pop())
return ''.join(reverse)
print ( reverse_string('Why is it not reversing completely?') )
Run Code Online (Sandbox Code Playgroud)