s.split()

  • Splits on any whitespace: spaces, tabs \t, newlines \n
  • Treats multiple whitespaces as one
  • Automatically removes empty strings from the result
  • Also trims leading/trailing whitespace

Example

"  hello   world  ".split() # ['hello', 'world']
 
"a\tb\nc".split() # ['a', 'b', 'c']
 
"   ".split() # []

s.split(" ")

  • Splits on the literal character " "
  • Does NOT collapse multiple spaces

Example:

"  hello   world  ".split(" ") # ['', '', 'hello', '', '', 'world', '', '']
 
"hello world".split(" ") # ['hello', 'world']