Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

From the Lists Chapter:

Lists are very easy to create, these are some of the ways to make lists:

emptyList = [ ]

strlist = ['one, two, three, four, five']

I find the "strlist" example very misleading, as a beginner might think we are creating a list of five strings, when it is actually just one string with some commas in it.



Likely an autopilot bug. It's almost second nature for a lot of coders to do this when making a list of strings.

strlist = 'one, two, three, four, five'.split(", ")

That habit probably just kicked in a little when putting in that example.


Indeed, although the commas are superfluous.


The space character argument is also superfluous as it is the default.

strlist = 'one two three four five'.split()




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: