0

Please.. I am having issues parsing this code. I don't seem to understand how the output gives []. Can anyone explain to me?

https://code.sololearn.com/c1Dv8ra9q5v5/?ref=app

25th May 2018, 9:00 AM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar
3 Réponses
+ 2
In general: this snippet filters out those values('$dollar', '@at','%modulu' ) that do not contain '
#x27; and '%' symbols. lambda operator creates an unnamed function that runs function 'any' through the values list. 'any' itself returns those elements that contains '
#x27; and '%' symbols. But 'not any' does a inverse selection. That is why you get those values that DO NOT contain '
#x27; and '%' symbols: f = lambda x: not any(p in x for p in fil) here: 'p in fil' runs across the list of
#x27; and '%' symbols one by one. So 'p' first takes '
#x27; and then in 'p in x' checks whether 'x' contains this synbol. Then the same goes with '%' synbol. 'x' in its turn is a variable that takes a value from the list ['$dollar', '@at','%modulu'].
25th May 2018, 12:53 PM
strawdog
strawdog - avatar
+ 1
strawdog thanks for pointing that out.. I just corrected it.. I still need explanation for the code though
25th May 2018, 11:26 AM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar
0
Looks like you've missed a comma in your list: lst = ['$dollar', '@at', '%modulu'] ^this one
25th May 2018, 11:19 AM
strawdog
strawdog - avatar