Python - can a dict have a value that is a list?

前端 未结 3 1829
甜味超标
甜味超标 2020-12-17 16:14

When using Python is it possible that a dict can have a value that is a list?

for example, a dictionary that would look like the following (see KeyName3\'s values):<

3条回答
  •  悲&欢浪女
    2020-12-17 16:39

    Yes, it's possible:

    d = {}
    d["list key"] = [1,2,3]
    print d
    

    output:

    {'list key': [1, 2, 3]}
    

提交回复
热议问题