+ 1

I don't know why my code is not working, Please help me fix it!!

It's a problem in the community section named "SUPER SALE". Here is my code:- https://code.sololearn.com/cGwB4kfjMxzK/?ref=app

14th Jul 2023, 2:14 PM
Vaibhav Pandey
13 Answers
+ 14
Vaibhav Pandey , https://code.sololearn.com/cb990KvXmvZ6/?ref=app Your code is working but in second line... instead int change it as float... like this... lst = [float(i) for i in expenses] Try it ....it works... And no need to copy the list and all... that you can remove the maximum value from the old list itself...
14th Jul 2023, 3:50 PM
Riya
Riya - avatar
+ 7
the code works now, anyway I want to make a few suggestions: > the core calculation of the savings can be shortened in one line, which makes it more readable. > the *rounding* by 2 methods (using round() and an own *method* with an if else conditional) is not quite obvious. so reading, understanding and maintaining can be difficult. > using your code base, i have done a slightly modification and I have commented out everything we don't need. https://code.sololearn.com/cr46P4ICKgOR/?ref=app
14th Jul 2023, 5:10 PM
Lothar
Lothar - avatar
+ 7
Vaibhav Pandey , i don't think that my solution is so much different from yours. the calculation that you have done in multiple lines are put together in one line. the only thing i have really changed is the *rounding* that is a floor rounding that i have implemented by using a convertion to int. int data type as result is required in the job description. the multiplication with 1.07 is used to add the tax to the price.
14th Jul 2023, 7:08 PM
Lothar
Lothar - avatar
+ 5
Manoj Kumar S , You have to calculate the savings you got after purchasing things with 30% discount and 7% tax... It is a problem in code coach...you may go through it for understanding the problem statement better....
14th Jul 2023, 4:01 PM
Riya
Riya - avatar
+ 5
Vaibhav Pandey , You're welcome:-) In code coach problem the sample input is in float... that's why I change it as float...go through the problem statement....
14th Jul 2023, 4:54 PM
Riya
Riya - avatar
+ 4
Leeroy Mokua , i am not sure what you are talking about in youd last post. can you please explain?
16th Jul 2023, 10:57 AM
Lothar
Lothar - avatar
+ 2
Vaibhav Pandey What are you trying to achieve with your code?
14th Jul 2023, 3:52 PM
Manoj Kumar S
+ 2
Riya Thank you very much. Btw how did you find such a small mistake!!!!
14th Jul 2023, 4:29 PM
Vaibhav Pandey
+ 2
Thanks for helping me understand it Riya
14th Jul 2023, 4:44 PM
Manoj Kumar S
+ 2
The code is working but your description of changing it to an integer instead you change it to a float.
15th Jul 2023, 10:26 PM
Leeroy Mokua
Leeroy Mokua - avatar
+ 1
Lothar That was literally just 5 lines bro,you are on whole another level. But I didn't understand how you figure out the 1.07 part???
14th Jul 2023, 5:45 PM
Vaibhav Pandey
+ 1
Lothar Thank you
15th Jul 2023, 2:23 AM
Vaibhav Pandey
0
Hey Riya What is the code expected to do?
14th Jul 2023, 3:56 PM
Manoj Kumar S