问题遇到的现象和发生背景
运行报错:
AttributeError: 'int' object has no attribute 'append'
用代码块功能插入代码,请勿粘贴截图
序号=[]
数字=[]
for 数 in range(1,10):
数字.append(数)
for 数字 in 数字:
if 数字==1:
序号.append('1st')
elif 数字==2:
序号.append('2nd')
elif 数字==3:
序号.append('3rd')
else:
序号.append(str(数字)+'th')
print(序号)
运行结果及报错内容
AttributeError: 'int' object has no attribute 'append'
我的解答思路和尝试过的方法
尝试用list(),没有解决
我想要达到的结果
序号='1st,2nd,3rd,4th,5th……'