我已经编写了这个函数来解析我创建的缩写和含义词典。但它对较长的缩写词不起作用。我认为这是找到第一个片段并把它吐出来。我希望它获取整个输入并返回响应该输入的值。单字母和双字母基本上都有效,但较长的字母是不行的
我的密钥示例:值 {'b00n':['new person'],'hv':['have'],'wuwtb':['you want to talk'],'l8rz':['later'],'jhm':['just hold me']
def main():
game = True
myDict = CreateDictionary('textToEnglish.csv')
print(myDict)
while game == True:
abbrev = input("Please enter text abbreviations seperated by comma:")
newList = list(abbrev)
print([v for k, v in myDict.items() if k in newList])
answer = input("Would you like to input more abbreviations? yes(y) or no(n):")
if answer == "y":
game = True
else:
game = False
abbrev是一个字符串,当您将其转换为列表时,您将得到每个字母的列表:
您可能需要这样的内容:
相关问题 更多 >
编程相关推荐