知识点:
1.字符串和字符的一些转换
2.剔除特殊数值的语句
3. for和return的缩进问题 (通过链接进行讲解)
python 缩进问题 - pursuer.chen - 博客园www.cnblogs.com4.不要马虎:( int(i) for i in 函数 if i !=0 )
题目:You are given a positive integer. Your function should calculate the product of the digits excluding any zeroes. For example, the number given is 123405. The result will be 1*2*3*4*5=120 (don't forget to exclude zeroes).
Input: A positive integer.
Output: The product of the digits as an integer.
正确解析:
错误解析:
错误原因:
[i for i in number_list if not i == 0]
In that i are strings, so it’s never == 0, but can == '0’.
注意注意注意!!!