[問題] 用modulus看是否整除 不知道哪裡出錯?
哈囉大家好,
我真心不知道自己錯在哪裡
我寫的可以通過第一個測試
但第二個又掛掉
糾結了幾天 沒辦法來向大家求教
感謝各位高手!
Write a program that reads two positive integers a and b on separate lines.
If a is divisible by b, print the message "divisible". Otherwise, print the
message "not divisible".
我的code:
a=int(input()[0])
b=int(input()[-1])
a>0
b>0
if a%b==0:
print("divisible")
else:
print("not divisible")
我的感覺是沒什麼問題吧
但通過了第一個測試
第二個就跟我說答案錯誤
請問我是否忽略了什麼細節呢?
大家端午節快樂!
--
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 68.180.87.229 (美國)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1559950068.A.D6A.html
→
06/08 08:09,
5年前
, 1F
06/08 08:09, 1F
→
06/08 08:10,
5年前
, 2F
06/08 08:10, 2F
→
06/08 10:20,
5年前
, 3F
06/08 10:20, 3F
推
06/08 12:49,
5年前
, 4F
06/08 12:49, 4F
→
06/08 14:46,
5年前
, 5F
06/08 14:46, 5F
→
06/08 14:46,
5年前
, 6F
06/08 14:46, 6F
→
06/08 14:46,
5年前
, 7F
06/08 14:46, 7F
→
06/08 14:58,
5年前
, 8F
06/08 14:58, 8F
→
06/09 11:27,
5年前
, 9F
06/09 11:27, 9F