Nov-09-2021, 11:01 AM
(This post was last modified: Nov-09-2021, 11:01 AM by ibreeden.
Edit Reason: Sorry Larz, we were almost at the same time answering
)
(Sorry Larz, we were almost at the same time answering.)
Very well, you are making progress. But you should be more precise than saying: " but didn't work as well". You get the following message, right?
In the function get_data() you have a return in the for-loop. That is wrong. You must return after the loop has finished. So unindent the return statement.
Very well, you are making progress. But you should be more precise than saying: " but didn't work as well". You get the following message, right?
Error:Traceback (most recent call last):
File "/home/ibreeden/PycharmProjects/Forum/venv/impos01.py", line 23, in <module>
output = get_data(data, key)
NameError: name 'key' is not defined
It is because you write:get_data(list_1,'length') output = get_data(data,key)Replace that with:
output = get_data(list_1, 'length')
Output:19.75
Now this is still not what you want, because this is only the first occurence.In the function get_data() you have a return in the for-loop. That is wrong. You must return after the loop has finished. So unindent the return statement.
Output:20.34
Still not what you want, now it shows only the last occurrence. Have a look at the list "y = []". Do you know how to append() values to a list?