【Python 學習筆記】巧用list 實現100之內被3整除的數

1.常規寫法:python #! /usr/bin/env python #coding:utf-8 aliquot = [] for n in range(1,100): if n%3 == 0: aliquot.append(n) print aliquot app 2.用list實現:utf-8 aliquot = [ x for x in range(1,100) if x%3==0 ] 
相關文章
相關標籤/搜索