+ 1

How to solve this problem?

the code, sentence=[['this','is','beautiful','and','nice','place'],['nice','place']] adjective=['beautiful','nice'] freq={} a=1 for sent in sentence: for x in sent: if x in adjective: freq [a]={} freq [a][x]=sent.count (x) a+=1 print (freq) the output I'm getting is, {1:{'nice':1},2:{'nice':1}} bt i need the following output, {1:{'beautiful':1},{'nice':1},2:{'nice':1}}

22nd Jan 2018, 11:57 AM
Initiator
2 ответов
+ 3
for sent in sentence: freq [a]={} for x in sent: if x in adjective: freq [a][x]=sent.count (x) a+=1 You tossed your result
22nd Jan 2018, 12:04 PM
John Wells
John Wells - avatar
+ 2
Thank you sir😊
22nd Jan 2018, 12:09 PM
Initiator