Problem with the Skee-Ball challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Problem with the Skee-Ball challenge

My code doesn't pass test 3 and I don't see a possible problem. I count how many tickets I get out of my points and then I count how many prizes it buys me. If it's more than one, I print the required string. Please help. https://code.sololearn.com/cQJNku0OVZWx/?ref=app https://www.sololearn.com/coach/21?ref=app

17th Feb 2020, 4:20 PM
Pavel
Pavel - avatar
11 Answers
0
I think that in 3rd test case price of the gun is 0. So ur code is giving divide by zero error.
17th Feb 2020, 5:52 PM
Peter Parker
Peter Parker - avatar
+ 1
Damn you're right, thanks.
17th Feb 2020, 5:47 PM
Pavel
Pavel - avatar
0
Pavel I used / in my code (instead of //)
17th Feb 2020, 4:45 PM
Denise Roßberg
Denise Roßberg - avatar
0
I used // because I don't care about what's left after the division. I can try it, but if it works, I still won't know why.
17th Feb 2020, 4:48 PM
Pavel
Pavel - avatar
0
Update: I used / with the same result.
17th Feb 2020, 4:51 PM
Pavel
Pavel - avatar
0
Pavel I could imagine that it has to do with precision. This is should work: if points / 12 >= price:
17th Feb 2020, 5:29 PM
Denise Roßberg
Denise Roßberg - avatar
0
Hari Shankar Good thought! I guess you could be right.
17th Feb 2020, 5:54 PM
Denise Roßberg
Denise Roßberg - avatar
0
Hari Shankar I controlled for the division by zero and it works now. You can see the code under the original link. Thank you.
17th Feb 2020, 6:10 PM
Pavel
Pavel - avatar
0
print({True : "Buy it!", False: "Try again"}[int(input(" "))/12 >= int(input(" "))])
5th Jul 2020, 7:25 AM
Akmal iman
Akmal iman - avatar
0
x=int(input()) y=int(input()) if ((x/12)>=y): print("Buy it!") else: print("Try again") It's simple and easy try copy pasting in exact same way.
31st May 2022, 11:28 AM
Hrithika Reddy
Hrithika Reddy - avatar