Re: [問題] 簡單的迴圈問題已刪文
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
討論串 (同標題文章)
Python 近期熱門文章
PTT數位生活區 即時熱門文章