a list is a structure that contains a series of values of any type.
if we have a list like [10, 20, 30, 40] the first element (as in all computer science) is an elemet #0
so we start counting from 0 not from 1 as in regular life.
if we need to get the first element of the array (list) we use arr[0] (arr is a name of the array/list)
when we iterate over the array using the for loop we get each consecutive element of that array with each loop. for i in data means "take each element of data one at a time".
so at loop 0 we take the 0th element and write its value to the variable i
here each element of the data list is a list itself, i.e. the 0th element is equal to [18, 20]
so i[0] means 18 and i[1] means 20. if we try to get the 2nd element of the list i we would encounter an error because there is no 2nd element in this array/list.
using words like 'key' and 'value' in this case is a bit wrong.
same logic
Complitly agryment!
This is best practice rather than the one liner most popular answer because this is much more readable.
The exact same thing i did rofl
your approach was unique
same here lol
Practicly i had the same solution jajaja
I had a similar approach!
same code with me :D
are you sure that you gave the conditions correctly?
The age is mentioned as atleast 55 ie >= 55.
This is what caused the error in my first test run as one test value was (55,21).
i did the same but few of them passed rest didn't i don't know why
Hi JoshK.py!
Yes, you are right. Dictionaries are different structures than lists.
There are no key:value pairs in lists.
Brdgs, MoniaJ
Waow i did the same
Hi Slysenko,
Thank you very much!
I think I totally get it now. Please become a Python professor!
Thank you again,
Josh
a list is a structure that contains a series of values of any type.
if we have a list like [10, 20, 30, 40] the first element (as in all computer science) is an elemet #0
so we start counting from 0 not from 1 as in regular life.
if we need to get the first element of the array (list) we use
arr[0]
(arr
is a name of the array/list)when we iterate over the array using the
for
loop we get each consecutive element of that array with each loop.for i in data
means "take each element ofdata
one at a time".so at loop 0 we take the 0th element and write its value to the variable
i
here each element of the
data
list is a list itself, i.e. the 0th element is equal to [18, 20]so i[0] means 18 and i[1] means 20. if we try to get the 2nd element of the list
i
we would encounter an error because there is no 2nd element in this array/list.using words like 'key' and 'value' in this case is a bit wrong.
Loading more items...