我想写一个基本程序,将内容从变量“a”复制到变量“b”,但顺序相反,例如:a=“toy”到b=“yot”
我的代码:
a="toy"
index= len(a)
indexm=0
new=" "
while(index>0):
new[indexm]==a[index]
index=index-1
indexm=indexm+1
print(new)
我收到以下错误消息:
IndexError: string index out of range
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-56-c909e83737f5> in <module>()
5
6 while(index>0):
----> 7 new[indexm]==a[index]
8 index=index-1
9 indexm=indexm+1
IndexError: string index out of range
我想解决它不使用内置函数来学习程序员的思维。 先谢谢你
试试这个:
相关问题 更多 >
编程相关推荐