python - Difference between [y for y in x.split('_')] and x.split('_') -


i've found this question , 1 thing in original code bugs me:

>>> x="alpha_beta_gamma" >>> words = [y y in x.split('_')] 

what's point of doing this: [y y in x.split('_')]? split returns list , items aren't manipulated in list comprehension. missing something?

you're correct; there's no point in doing that. however, it's seen in combination kind of filter or other structure, such [y y in x.split('_') if y.isalpha()].


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -