小编Kab*_*bra的帖子

Python3.x:如果/ Else麻烦

我的if/else语句遇到了一些问题.这是我的代码,问题在代码本身的多行注释中描述:

def cube(*number):
    return number**3
def by_three(number):
    if number/3==0: #Checks if number is divisible by 3.
        cube_of=cube(number) #Cubes number.
        print(cube_of) #Prints cube of number.
        return False
    else:
        print("Your number isn't divisible by three. Try again.") #Comment is below
        """
        Tells if number is not divisible by three. If I give 9 as the argument, 
        this block is executed. Why so?
        """
        return True
while True:
    by_three(int(input("Give me any number divisible by three: ")))
Run Code Online (Sandbox Code Playgroud)

问题出在代码中.请在答案中使用简单的术语,因为我只是初学者.

python if-statement python-3.x

-1
推荐指数
1
解决办法
89
查看次数

标签 统计

if-statement ×1

python ×1

python-3.x ×1