1

If I have any list x

x=[]

When adding a string (iterable) to it, it doesn't work

x = x + 'welcome'

Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "str") to list

While addition assignment works

x+='welcome'
['w', 'e', 'l', 'c', 'o', 'm', 'e']
Barmar
  • 669,327
  • 51
  • 454
  • 560
Ehab
  • 452
  • 5
  • 21

0 Answers0