0
On Dictionary
Pls I tried this code: food={ "Lettuce":5, "Carrot":4, "Mango":10, "Chesseburger":0,} count=0 foods=input() y=foods.split(" ") for i in y: z=food.get(i) count=count+z print(count) >>It didn't work on Solo learn but did on my laptop .it is a practise question Izzy iguana on code coach Thank u
11 Respostas
+ 1
What does Sololearn say?
Also, you don't need comma in the last dictionary item, since there are no more items afterwards
+ 1
It works you just didnt do the check if it greater then some value print something not the sum
reread the problem
+ 1
Try this.
snacks = input()
s_snacks = snacks.split()
count = 0
points = {
"Lettuce": 5,
"Carrot": 4,
"Mango": 9,
"Cheeseburger": 0
}
#iterate available snacks
for s_snack in s_snacks:
if s_snack in points:
count += points[s_snack]
if count >= 10:
print("Come on Down!")
else:
print("Time to wait")
0
Ion Kare sorry I dont understand wht ur saying
0
Oyedeji Hiqmat
"You need 10 total snack points to bring it down. Lettuce is worth 5, Carrot is worth 4, Mango is worth 9, and Cheeseburger is worth 0."
"Task:
Evaluate whether or not you have enough snack points to convince your iguana to come down."
"Output Format:
A string that says 'Come on Down!' if you have enough points, or 'Time to wait' if you do not. "
0
Ohh I didnt finish it
0
Ion Kare but thanks
0
Mwaüra thank u very muh
0
Mwaüra didnt have to change the whole code , he just needed to remove the print(count) with -> if count >= 10 : print("come on down") else: print("time to eat")
0
Hello
0
Answers