I have been experiencing frustration with the precision and specific examples required to get credit in the Data Science Foundations Exam.
I have just submitted question 2 (asking to order by Grade) but for whatever reason despite pulling that exact data, i was not given credit. I am now 2 “check answers” down on question 4:
with my answer as follow:
for x,y in all_items:
if y%2 == 1:
discounted_items.append(x)
For testing purposes: print discounted list
print(discounted_items)
the check is telling me I haven’t run the loop? What am I missing?? This is incredibly frustrating I’ve done this exam 3 times now, and have been able to pull the exact data for every entry- but routinely get credit for only 4/6, marking as an incomplete grade.
I can’t view the exam, but I am just wondering whether the instructions give any examples.
Is the result supposed to be a list of strings or is it supposed to be a list of lists i.e.
Is discounted_items supposed to be:
['Taffy', 'Cup', 'Bowl']
or is it supposed to be:
[['Taffy', 1], ['Cup', 5], ['Bowl', 11]]
? Do the instructions include an example of sample output?
Hi,
Sorry for my bad english, I’m french.
I’ve the same frustation.
I think that before run the odd list, we have to run a “simple loop” .
Tomorow I’ll test this :
Hi,
Did you find any solution ? I’m stuck too it’s very frustrating I don’t understand why they keep telling me that I haven’t run the loop … I’m missing something idk what
Well I got it to work. You have to use a for i in range(len(some_list)): loop rather than a for x, y in some_list: loop. Then access the elements of the lists by their index. WAY to picky in my opinion.
hello there, been stuck on this question for a while now. Tried your code, works for the most part but now it’s asking if I’ve included print(dicsounted_items) at the end of my code.
Here’s how I typed it did I type it incorrectly somehow?
This is essentially what I did but it’s telling me to make sure to print the discounted items list at the end of my code. Not sure where this is going wrong but it prints out correctly.
# All of our store items
all_items = [["Taffy", 1], ["Chocolate", 2], ["Cup", 5], ["Plate", 10], ["Bowl", 11], ["Silverware", 22]]
# Empty discounted_items list
discounted_items = []
# Your code here
for item in all_items:
if item[1] % 2 != 0:
discounted_items.append(item)
print(discounted_items)
# For testing purposes: print discounted list
# print(discounted_items)
First of all, I noticed that your code has some syntax errors that might prevent it from running correctly. For example, you are using curly quotes (“ ”) instead of straight quotes (" ") for your strings and list elements. You also need to indent your code properly to show the structure of your loop and conditional statement. Here is how your code should look like:
# All of our store items
all_items = [["Taffy", 1], ["Chocolate", 2], ["Cup", 5], ["Plate", 10], ["Bowl", 11], ["Silverware", 22]]
# Empty discounted_items list
discounted_items = []
# Your code here
for x,y in all_items:
if y%2 == 1:
discounted_items.append(x)
# For testing purposes: print discounted list
print(discounted_items)
no they do not give sample print outs at the exam levels, even though they sometimes do at the exercise level, and it helps a great deal.
So, the problem with the exam is that they only give you 3 times to check the answer, it is very frustrating.
My code is: