20.3 ice cream help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

20.3 ice cream help

Let's imagine you want to buy an ice-cream for 10 of your friends. Write a program that will take the money you have and the price of one ice-cream, and will output the remaining money only if you can buy that ice-cream for your all 10 friends. Sample Input 80 7 Sample Output 10 Explanation To buy 10 ice-creams you need 7*10 = 70. The remaining money is 80-70 = 10. ___________________________________________ money = int(input()) price = int(input()) total = price * 10 change = money - total if (total>80): print() else : print(change) Hi everyone, I've tried like 5 different ways, every single time it test #2 fails. If anyone can help on how to pass test 2 or even what it means so for future I can figure out the bugs.

16th May 2021, 7:39 PM
Faz 'Straps' Zaf
Faz 'Straps' Zaf - avatar
6 Answers
+ 2
You should attach the task description to get help from users without pro subscription Empty print is most likely unnecessary. So you could simplify your code like this: total = price * 10 if total <= 80: print(money - total)
16th May 2021, 7:56 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Apologies Benjamin, I have added the actual problem to solve. Also switching to the end part of your hint made it fail test 1 and 2 but 3-5 were correct.
16th May 2021, 7:59 PM
Faz 'Straps' Zaf
Faz 'Straps' Zaf - avatar
0
Please, show your edited code again
16th May 2021, 10:26 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
money = int(input()) price = int(input()) total = price*10 remainder = money-total if (total>money): print() else : print(remainder) This satisfied all tests.
18th May 2021, 8:50 AM
Faz 'Straps' Zaf
Faz 'Straps' Zaf - avatar
0
Or this: money = int(input()) price = int(input()) needed = price*10 cash_left = money - needed if money < needed: print(" ") else: print(cash_left)
3rd Jul 2021, 1:13 AM
Chris
Chris - avatar
0
first thanks @Faz 'Straps' Zaf for the solution we are not told about any remainder or to create a variable to get this. so how were we suppose to know? id like to know so i can learn and continue. Thanks. money = int(input()) price = int(input()) total = price*10 remainder = money-total if (total>money): print() else : print(remainder)
28th Dec 2021, 1:25 AM
Mike