可是不让用 print, input..怎么写函数来实行?

比如把
[['cola', 'juice', 'coffee', 'tea'],
['cola', 'juice', 'tea', 'coffee'],
['cola', 'juice', 'coffee', 'tea']]
转换成
{('cola', 'juice', 'coffee', 'tea'): 2,
('cola', 'juice', 'tea', 'coffee'): 1}
在编译器中
for i in a:
if(b.has_key(tuple(i))==False):
b[tuple(i)]=1
else:
b[tuple(i)]+=1
是可行的

ibeautiful
浏览 72回答 2
2回答

哆啦的时光机

python3.2a=[['cola', 'juice', 'coffee', 'tea'],['cola', 'juice', 'tea', 'coffee'],['cola', 'juice', 'coffee', 'tea']]b={}for i in a:i=str(i)b[i]=b.get(i,0)+1print(b)

慕桂英3389331

不明白什么意思,需要input输入的是什么数据???输入一个列表还是列表中的元素???
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python