###前提・実現したいこと
Pythonのコードについて、短縮の仕方がまずいかどうか教えて欲しいです。
また、他に良い短縮の仕方があれば教えて欲しいです。
###該当のソースコード
python
1"""before""" 2def countNum(numlist): 3 counter = 0 4 for num in numlist: 5 if 条件: 6 counter += 1 7 return counter 8 9"""after""" 10def isMach(num): 11 return 1 if 条件 else return 0 12 13def countNum(numlist): 14 return sum([isMach(num) for num in numlist])
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/15 14:38
2017/06/15 14:45
2017/06/15 14:54
2017/06/16 07:44