Re: [問題] 簡單的迴圈問題已刪文

看板Python作者 (韋恩)時間6年前 (2019/06/24 08:31), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
5行就可以了 不知道有沒有更好的解法 number = int(input()) ans = [] for i in range(1,number): if len(str(pow(i,0.5)))<4: ans.append(i) print(ans) pow():找出引數1的引數2次方,這裡輸入0.5相當於開根號 <4:因為開根號結果如果是整數至少會是三個字元 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.127.247.76 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1561336312.A.6DD.html
文章代碼(AID): #1T41duRT (Python)
文章代碼(AID): #1T41duRT (Python)