程序运行无法结束
import math;
def dictSlice(dic, n, m):
# print dic;
lst = dic.keys();
# print lst;
lst = sorted(lst, lambda x, y: cmp(x, y));
# print 4;
lst = lst[(n - 1 if(n <= m) else m - 1): (n if(n >= m) else m)];
newDic = {};
for i in lst:
newDic[i] = dic[i];
# print newDic;
return newDic;
newLst = [];
reLst = [];
while True:
try:
# print math.min(9, 9);
n = raw_input();
# print n;
inLst = map(int, n.split(' '));
# print inLst;
lst1 = map(int, raw_input().split(' '));
lst = zip(range(1, inLst[0] + 1), lst1);
# print lst;
dic = dict(lst);
# print dic;
while(inLst[1] >= 1):
inLst[1] = inLst[1] - 1;
# print 1;
newLst = raw_input().split(' ');
# print int(newLst[1]);
if newLst[0] == 'Q':
# print 2;
dic1 = dictSlice(dic, int(newLst[1]), int(newLst[-1]));
reLst.append(dic1.get(max(dic1, key = dic1.get)));
elif newLst[0] == 'U':
dic[int(newLst[1])] = int(newLst[2]);
for num in reLst:
print num;
except:
break;我的代码在最后一次输入之后打印完不能结束是为什么,是哪里出了错误?
谢谢