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
  • 741,623
  • 53
  • 500
  • 612
Ehab
  • 566
  • 6
  • 24

0 Answers0