你贴的代码,就缩进有点问题,其他运行正常啊,然后不知道你是不是要保留输入的内容还是不保留,每次都输出一个的话就把前三句放到循环里重置为空,要保留的话就放循环外while True:
numlist = []
list1 = []
new = ''
a=input('请输入浮点数')
if a=='x':
break
else:
numlist.insert(0,a)
for i in range(len(numlist)):
for j in range(len(numlist[i])):
while True:
if numlist[i][j]=='1' or numlist[i][j]=='3' or numlist[i][j]=='5' or numlist[i][j]=='7' or numlist[i][j]=='9':
new=str(numlist[i])[:j]+'8'+str(numlist[i])[j+1:]
#print(new)
del numlist[i]
numlist.insert(0,new)
continue
else:
break
#print(numlist)
n=len(numlist)
for z in range (n):
c=0
for l in range (0,n-1-z):
if numlist[l] > numlist[l+1]:
numlist[l],numlist[l+1] = numlist[l+1],numlist[l]
c+=1
if 0==c:
break
for u in numlist:
print(u)
|