Ballpark Order Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Ballpark Order Question

Hey folks, I am having trouble figuring out why my code passes the visible tests but not the hidden ones. I tried manual test strings and they appeared to process correctly. I attempted a strip command to remove any potential whitespace or new lines however this did not seem to have an effect. I'm sure I'm missing something obvious and would really appreciate any help. Sidebar - I know it can be solved by using the split method and iterating over the list created from the string, but I wanted to try this manner of resolving the problem if possible. https://code.sololearn.com/c4U2q2RAp6N3/?ref=app

23rd Aug 2020, 9:22 PM
Michael Lawton
Michael Lawton - avatar
5 Answers
+ 1
Michael Lawton I tested it with the output in currency format and it passed all tests, i then tested it without the currency format and it only passed the first two. The reason why I think that is the issue is if you print a "Coke" you get a long float, which is what I think is failing the other tests. Also the below should work too... print(round(total*1.07,2))
23rd Aug 2020, 9:58 PM
Steven M
Steven M - avatar
+ 1
Try formatting your output for currency? print(f'{total*1.07:,.2f}')
23rd Aug 2020, 9:39 PM
Steven M
Steven M - avatar
+ 1
Steven M formatting didn't seem to resolve the issue unfortunately. I appreciate the suggestion though! The coke option is the default if an input does not match any of the criteria, so I included that in the final else. I should have placed that in a comment. My bad!
23rd Aug 2020, 9:52 PM
Michael Lawton
Michael Lawton - avatar
+ 1
Steven M you're 100% right and my apologies! I looked back at the edited code and I had formatted improperly when I went to double check your suggestion. Thank you!
23rd Aug 2020, 10:06 PM
Michael Lawton
Michael Lawton - avatar
+ 1
Michael Lawton no worries man, its good code 👍
23rd Aug 2020, 10:08 PM
Steven M
Steven M - avatar