I have a list I generate like this:
cols = [td['data-stat'] for td in rows[0].find_all("td")]
cols contains:
['age','team_id','lg_id','pos','g','gs','mp','fg', ...]
as it should. However, when I insert "season" to the beginning OR extend ["season"] with cols, I suddenly get NoneType:
new_cols = ["season"].extend(cols)
Any ideas?
The
list.extend()method doesn't return a value, it alters an existing one.If you want a separate list that contains every element in the
colslist, along with the"extend"string, use thelist.copy()method to duplicate the list, and use thelist.extend()method on the new list:If you do not intend to keep the old list, then you can directly use the
list.extend()method on the old list: