猿问

python遍历字典中的列表出错,list中的汉字换成字母也不行,请教大神这是什么情况?

favorite_places={'小明':['上海','北京','深圳'],'小王':['上海','南京'],'小张':['上海','南京']}
for name,favorite_place in favorite_places.items():
    print('somewhere of 'name +' liking are'+ ' : ')
         for fa_place in favorite_place:
             print(fa_place)


 提示: File "C:\Users\Xiaofei\Desktop\python从入门到实践练习题\6\6-8.py", line 3
    favorite_places={'小明':['上海','北京','深圳'],'小王':['上海','南京'],'小张':['上海','南京']}
                                              ^
SyntaxError: invalid character in identifier
[Finished in 0.4s]

yxiaofei
浏览 1325回答 1
1回答

产品经理不是经理

你的很多逗号都是中文逗号,修改其中的逗号为英文逗号就没问题了?
随时随地看视频慕课网APP

相关分类

Python
我要回答