Duty Free fails on test 3 (python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Duty Free fails on test 3 (python)

This passes all but test 3 https://sololearn.com/coach/59/?ref=app dollar = list(map(lambda x: float(x) * 1.1, input().split(" "))) #print(dollar) def eval(list): for i in list: if i > 20: return "Back to the store" return "On to the terminal" print(eval(dollar))

10th Jan 2021, 11:57 PM
Jacob Hargrave
Jacob Hargrave - avatar
5 Answers
0
Ok, so I definitely think it should work if you put the last return outside the for loop. I think you could even do it in one line like this: print("Back to the store" if any( map( lambda x: float(x) *1.1 > 20, input().split(" ") ) ) else "On to the terminal") But one-liners are not always the solution :)
11th Jan 2021, 5:48 AM
Angelo
Angelo - avatar
+ 1
I'm not a pro, so I cannot see what the problem is asking for. But I feel like the second return in eval should not be inside the for (maybe you meant to use yield? Since you are working with an iterable)
11th Jan 2021, 4:35 AM
Angelo
Angelo - avatar
0
Angelo, thanks for the response. Here's the code coach instructions. It does not appear to want a sequence of answers, just an overall "Back to the store" if the price limit is exceeded or "On to the terminal" if it isn't. Test 1 results in "Back to the store" correctly and test two is the opposite, correctly. No idea what test 3 is, but all the other tests pass. You make a purchase of souvenirs priced in Euros at a duty free store in the Rome airport. You didn't want to spend any more than 20 US Dollars on any specific item. Can you go through your list and make sure you stayed under your limit? The conversion rate on this day is 1.1 US Dollars to 1 Euro. Task: Evaluate each item that you purchased to make sure that you didn't spend more than $20 on that particular item. If you did, you will need to go back to the store to return it. Input Format: An string of numbers separated by spaces that represent the prices of each of your items in Euros. Output Format: A string that says 'On to t
11th Jan 2021, 4:43 AM
Jacob Hargrave
Jacob Hargrave - avatar
0
Angelo, yes, you were right about moving the return to the for loop instead of the if statement. Thanks!
11th Jan 2021, 8:35 AM
Jacob Hargrave
Jacob Hargrave - avatar
0
items = input().split(" ") num = max([eval(i) for i in items]) if num * 1.1 > 20: print('Back to the store') else: print('On to the terminal')
7th Jul 2023, 3:18 PM
BrightJ
BrightJ - avatar