This problem is from the practice pack in the computer science path. I don’t remember learning .omit in the course and I’m not sure how to answer this problem. What is the answer and how does .omit work?
Thanks
what does important_data
look like? Or you can provide the lesson?
.omit
seems to be a property added to the data by who-ever created that data list
so we could omit certain data if desired.
That’s all the info from the practice pack. There’s no other info and i can’t even link this because it is just a random problem from the practice pack
I have no idea what the data is, but I suspect the data pack contains a list with objects (class instance) which have a .omit
property
can’t you do: print(data_list)
, and copy that code to the forum so I have an idea what the data pack looks like?
I moved on from that problem and I can’t access it anymore. I just wanted to see if someone else could figure it out but nevermind. I’m just gonna move on
I still by my point that its a property of the object/class instance. Given the syntax used, I am 90% sure. The extra 10% would have been nice (to see the data/exercise), but isn’t a must
Hello @stetim94,
I accessed this problem myself today and I am also stuck.
To answer your question, if you print the data list you get: [2, 6, 123, 81, 30, 582, 553, 893]
If you print the type of the number, print(type(number)), you get
<class 'important_data.ImportantNumber'>
Dunno if this helps to figure it out.
I came across the same thing today. I also didn’t learn omit, and when I was searching it up, found this forum.
I still don’t know what omit is, or most of this problem, but the idea is that it wants you to skip the number if the .omit thing is true.
I don’t know how or who set the omit, but to skip the number, you can put “continue” in the code.
So where the # notes are where it says to update the line, I just put continue in there, and got the problem right.
your data_list
contains objects/class instances. This object has an omit
property which is either set to True
or False
this is the exercise: https://www.codecademy.com/practice/tracks/learn-python-3/modules/learn-python3-loops
Any ideas of how to solve it?
should that be continue
instead of pass
in the for-loop ?
Hi! I just encountered the same problem on my practice.
I think the purpose of the exercisa is only to remember what “continue” does, which is actually the same as what “pass” would do, only that “pass” isn’t really part of loop control.
I just changed it to “continue” and done!
I found the answer after failed 3 times: It just changed the “pass” for “continue”, something I will never found! haha…
The Python continue word vs the pass word! Google it!
from important_data import data_list
aggregated_sum = 0
count_data = 0for number in data_list:
if number.omit == True:
# Update this line so that
# We omit this number
continueaggregated_sum += number
count_data += 1averaged_data = aggregated_sum / count_data
print(“Total average for our important data is {}”.format(averaged_data))