04-python第四天学习

In [1]: nums = [11,22,33,44]

In [2]: for temp in nums:
   ...:     print(temp)
   ...: else:    #else表示当循环打印完才会打印else里的内容
   ...:     print("========")
   ...:     
11
22
33
44
========

(1)for循环里的else

(2)列表append的注意点

In [3]: a = [11,22,33]

In [4]: b = [44,55]

In [5]: a.append(b)

In [6]: a
Out[6]: [11, 22, 33, [44, 55]]  #append相当于把b列表这个整体都放在a列表

In [1]: a = [11,22,33]

In [2]: b = [44,55]

In [3]: a.append(b)

In [4]: a
Out[4]: [11, 22, 33, [44, 55]]

In [5]: a = a.append(b)  #当执行a.append(b)时,代表已经把b添加到a里面去了,结果已经发生了变化,但是a.append(b)并没有结果输入,则会返回空

In [6]: a