[Solved] can someone please explain to me this code – python 3


Its simple,

d += 'a' + 'b' # is same as [] + list('ab') = ['a', 'b']

Similarly

d += ['a' + 'b'] # is same as [] + ['ab'] = ['ab']

When you type convert a string to list, it creates a list of individual character as elements of list.

For Example:

a = "Good"
b = list(a)
print(b) # will print as --> ['G', 'o', 'o', 'd']

solved can someone please explain to me this code – python 3