第26146题 判断题
判断给定代码能否将标签字符串"python,java,python,c++,java"转换为字典{'python': 2, 'java': 2, 'c++': 1}

在对用户输入的标签进行次数统计时,可以使用如下的方法,把标签字符串"python,java,python,c++,java"转换成为字典{'python': 2, 'java': 2, 'c++': 1}。

tags = "python,java,python,c++,java"
result = {}
for tag in tags.split(','):
    result[tag] = result.get(tag, 0) + 1
print(result)
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析