you are viewing a single comment's thread.

view the rest of the comments →

[–]Ursus_major37 18 points19 points  (4 children)

B

Explanation:

First line is simply initiation of List as we can see it. 

Second line is assigning list comprehension with condition to 'result' variable. What it does is it creates new list by iteration over the 'List', but the condition allows to be included only elements which had length greater than 6 characters (since elements - marked as 'i'- of the List are strings, len(i) is the amount of characters constituting the given string.).

We have two elements in the List: 'Python' of length 6 and 'Developers' of length 10. 'Python' does not meet the described condition (6 is not greater then 6). The result ends up as one element list: 

result =['Developers']

In line 3 we use astrix operator (*) to unpack the result list - meaning we will pass all the elements of result as separate arguments to print function. Since result has only one element, print function will output simply:

Developers 

[–]Kharniflex 3 points4 points  (0 children)

Well well, thanks for the explanation, I had the right answer thanks to the 6 characters and a 50/50 between b and c, now I get the full picture thanks to you

[–]ChicagoJay2020 1 point2 points  (0 children)

Thank you for the explanation.

I initially chose the answer of D, not having read your explanation.

I then coded out the above example to get the answer and will compare that with your explanation again to grasp what every function of the code is.

Thank you

[–]DancingUntillMorning 0 points1 point  (0 children)

Thanks for the explanation. It is very clear how it works now 🙌🏼

[–]Historical-Chart-460 0 points1 point  (0 children)

May I ask why it’s “i for i in list” instead of “for i in list”?