###やってみたいこと
記事(英語)から適当に引っ張ってきた文章に使われる単語をその出現回数とともにリストアップしたい。
(※記事の内容は適当に見つけたものを繋げたりしています)
###該当コード
python
1 2words=[] 3str=" The agency was given the prize for its efforts to combat hunger and improve conditions for peace. The WFP, the 101st winner of a prize now worth 10m Swedish krona ($1.1m; £875,000), said it was 'deeply humbled' to have won. Some 107 organisations and 211 individuals were nominated for the award this year. WFP head David Beasley told the BBC's Newshour he was in shock following the announcement. In the video, Mr Prasad says he and his wife start preparing the menu at 6.30am every morning and finish by 9.30am. The first lot of customers are usually informal workers or office-goers looking for a hearty breakfast. But the pandemic, which cost people their jobs or forced them to stay at home, has shrunk business. Mrs Prasad says that at times they take the unsold food back home, and on some days, they don't have money to cook a meal for themselves. But ever since the video went viral, the stall has seen a steady flow of customers, some of whom are eager to squeeze in a selfie with the now-famous spot. TV crews have been showing up as the stall and its owners continue to grab headlines. Bollywood actress Sonam Kapoor and cricketer R Ashwin are among those who have offered to help. Mr Wasan told ANI that he had come across Baba ka dhaba by chance. 'They told me that were making losses every day. So I made a video at the spot and shared it with my followers.' He adds that he has collected around $2,700 in donations to repair the stall and the couples house. The Prasads are both touched and elated. 'It is all because of Gaurav that the customers have lined up today,' Mr Prasad told ANI news agency. 'Yesterday there was almost no sales. Today I feel that the whole country is with us.' " 4for i in str.split(): 5 if type(i)!=int: 6 words.append(i.lower()) 7 for j in words: 8 print(j+': '+words.count(j)+'\n')
###エラー
Terminal上で以上のプログラムを実行すると、以下のエラーが出力されます:
python
1 File "/Users/***/Desktop/math.py", line 9, in <module> 2 print(j+': '+words.count(j)+'\n') 3TypeError: can only concatenate str (not "int") to str
###やってみたこと
様々な工夫をしてintの文字列が含まれない様にしたのですが、何故かその処理をする前した後同じ上のエラーが出力されます。お力添え頂ける箇所がございましたら、よろしくお願い申し上げます。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/09 16:56
2020/10/10 00:58
2020/10/10 01:03
2020/10/10 06:09
2020/10/10 06:46
2020/10/10 09:04
2020/10/10 09:14
2020/10/11 02:52