Python 程序的输出

问题描述 投票:0回答:1

This was the program以下程序的输出是什么?

word = 'brontosaurus'
d = dict()
for c in word:
    d[c] = d.get(c,0) + 2
print (d)

我在考试时遇到了这个问题。我想知道这个问题的正确答案。

dictionary for-loop jupyter-notebook output artificial-intelligence
1个回答
0
投票

当我运行代码时,我得到的输出是:

{'b':2,'r':4,'o':4,'n':2,'t':2,'s':4,'a':2,'u':4}

© www.soinside.com 2019 - 2024. All rights reserved.