Today I spent about 20 minutes trying to figure out why this worked as expected:
users_stories_dict[a] = s + [b]
but this would have a None value:
users_stories_dict[a] = s.append(b)
Anyone know why the append function does not return the new list? I'm looking for some sort of sensible reason this decision was made; it looks like a Python novice gotcha to me right now.
append()is not documented as returning a value. What caused you to think it did? Where did you get the idea that append returns a value? What documentation where you reading that suggested such a thing?users_stories_dict[a].extend(b)btwusers_stories_dict[a].extend(b)would only work ifbis an iterable. Assumingbis a string, comparea_list.append(b)anda_list.extend(b). BTW,list.extend()also returnsNonejust likelist.append()..append()returns a new list. its not an unreasonable assumption.