solve:create dictionary to solve
import sys
#create commend dictionary
command={'reset':'reset what','reset board':'board fault','board add':'where to add',
'board delete':'no board at all','reboot backplane':'impossible',
'backplane abort':'install first'}
keyl=list(command.keys()) #dict key is hashable,transform to unhashable
for ss in sys.stdin:
s=ss.lower().split()#input without distinguishing was tranformed to a list
a=len(s) #calculating input list length
if a==0 or a>=3:print('unknown command')
else:
if a==1:
if s[0] in keyl[0]:print(command[keyl[0]])
else:print('unknown command')
else:
num=0
knum=0
for i in range(1,6):
if s[0] in keyl[i].split()[0] and s[1] in keyl[i].split()[1]:
num+=1
knum=i
if num==1:print(command[keyl[knum]])
else:print('unknown command')
京公网安备 11010502036488号