Sep-23-2018, 08:34 PM
i can do
mylist+=mytuple
but i cannot do mylist=mylist+mytuple
. why is that?lt1/forums /home/forums 1> py3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a=[1,2,3] >>> b=(4,5,6) >>> a+=b >>> a=a+b Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only concatenate list (not "tuple") to list >>>
lt1/forums /home/forums 1> py2 Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a=[1,2,3] >>> b=(4,5,6) >>> a+=b >>> a=a+b Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only concatenate list (not "tuple") to list >>>and mylist.extend(mytuple) also works.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.