小编Sri*_*Sri的帖子

Python:字符串反向中途停止

我正在编写一个函数来反转一个字符串,但直到最后才完成它.我在这里错过了什么吗?

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)

python string reverse python-3.x

1
推荐指数
1
解决办法
86
查看次数

标签 统计

python ×1

python-3.x ×1

reverse ×1

string ×1