HJ66 配置文件恢复
按照题目意思直接做就可以了
while 1:
keys=["reset","reset board","board add","board delete","reboot backplane","backplane abort"]
values=["reset what","board fault","where to add","no board at all","impossible","install first"]
try:
s = input().split()
if len(s)<1 or len(s)>2:
print("unknown command")
continue
## 单字符 那就只有reset命令
elif len(s)==1:
if s[0]==keys[0][:len(s[0])]:
print(values[0])
else:
print("unknown command")
continue
## 两个字符 遍历
else:
commond =[]## 记录是否有多匹配命令
for i,k in enumerate(keys[1:],1):## 直接从1 开始遍历
k = k.split()
if s[0]==k[0][:len(s[0])] and s[1]==k[1][:len(s[1])]:
## 此时并不能直接输出
commond.append(values[i])
if len(commond) != 1 :
print("unknown command")
else:
print(commond[0])
except:
break