我有一个单词字典作为键,整数作为值。它输出如下:
print (word_ratings_dict)
{'hate': [1, 2, 2, 1, 1, 3, 0, 2, 3, 2, 0, 4, 1, 1], 'joy': [3, 4, 3, 3, 2, 4, 1]}
Run Code Online (Sandbox Code Playgroud)
对于字典中的每个关键字,我需要不使用统计模块来计算其标准差。
这是我到目前为止的内容:
def menu_validate(prompt, min_val, max_val):
""" produces a prompt, gets input, validates the input and returns a value. """
while True:
try:
menu = int(input(prompt))
if menu >= min_val and menu <= max_val:
return menu
break
elif menu.lower == "quit" or menu.lower == "q":
quit()
print("You must enter a number value from {} …Run Code Online (Sandbox Code Playgroud)