0
Where is the bug?
I did this Skee-ball challenge and all but one of the test case was wrong, why is that? Where is my mistake? Here's my code: score = int(input()) price = int(input()) yourTicket = score // 12 if yourTicket // price != 0: print("Buy it!") else : print("Try again")
4 Antworten
+ 7
You're right about // can produce 0 (a//b whenever a<b)
What about this way?
points, cost = int(input), int(input)
tickets = points // 12
print("Try again" if tickets < cost else "Buy it!")
+ 2
Let's say
yourTicket = 10
price = 10
10/10 = 1 # ! = 0 check
1 / 10 = 0.1 # also check but it shouldn't
If you cut a cake in x pieces the result is never 0
So your if never fails
+ 1
David Ashton Thanks, it's work!
0
Well, I'm using "//" operator, so it won't print out 0.1