擅长:python、mysql、java
<p>使用单个结果变量:</p>
<pre><code>def fun_divi(x):
res = ''
if (x % 2 == 0):
res += "divi"
if (x % 3 == 0):
res += "sible"
print("Not divisible by any" if not res else res.capitalize())
fun_divi(6) # Divisible
fun_divi(9) # Sible
fun_divi(5) # Not divisible by any
</code></pre>