.split() function doubt
If the characters in x are separated by spaces, they work the same way. If there are multiple whitespaces between the chacacters, they work differently as str(x).split(' ') splits specifically by each space and str(x).split() splits by consecutive whitespace.

Example:

test_cases = ["a b c", "a   b   c"]
for x in test_cases:
    splitted_by_space = x.split(" ")
    splitted_by_consecutive_ws = x.split()
    print("x =", '"' + x + '"')
    print('x.split(" ") --&gt;',  splitted_by_space)
    print('x.split()    --&gt;',  splitted_by_consecutive_ws)
    print("-" * 50)


Output:

x = "a b c"
x.split(" ") --&gt; ['a', 'b', 'c']
x.split()    --&gt; ['a', 'b', 'c']
--------------------------------------------------
x = "a   b   c"
x.split(" ") --&gt; ['a', '', '', 'b', '', '', 'c']
x.split()    --&gt; ['a', 'b', 'c']
--------------------------------------------------


From the official documentation:


  str.split(sep=None, maxsplit=-1)
  
  If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a None separator returns [].