如果我正确解释您的问题,您只需要设计一个非常简单的列表理解程序即可。
不需要在零和n之间获得所有事物的平方根。你是刻空的吗?
这是我的解决方案:
def nbDig(n,d): int_list = str([str(x*x) for x in range(0,n+1)]).count(str(d)) return int_list
我可以像这样测试:
nbDig(12,1)
返回7。
编辑:我没有意识到呼叫。重新定位是完全不必要的。感谢您的反馈!
If I am interpreting your question correctly, you simply need to devise a very simple list comprehension program.
Getting the square root of everything between zero and n is not necessary. Did you mean square?
Here's my solution:
I can test it like so:
This returns 7.
EDIT: I didn't realize calling .replace was totally unnecessary. Thanks for the feedback!
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
如果我正确解释您的问题,您只需要设计一个非常简单的列表理解程序即可。
不需要在零和n之间获得所有事物的平方根。你是刻空的吗?
这是我的解决方案:
我可以像这样测试:
返回7。
编辑:我没有意识到呼叫。重新定位是完全不必要的。感谢您的反馈!
If I am interpreting your question correctly, you simply need to devise a very simple list comprehension program.
Getting the square root of everything between zero and n is not necessary. Did you mean square?
Here's my solution:
I can test it like so:
This returns 7.
EDIT: I didn't realize calling .replace was totally unnecessary. Thanks for the feedback!