TypeError: 'NoneType' object is not iterable到底时什么原因导致的,代码哪里有问题?已解决。

>>> values=list(range(1,11)).extend('Jack Queen King'.split(' '))
>>> suits='diamonds clubs hearts spades'.split(' ')
>>> deck=['%s of %s'%(v,s)for v in values for s in suits]
Traceback (most recent call last):
  File "<pyshell#42>", line 1, in <module>
    deck=['%s of %s'%(v,s)for v in values for s in suits]
**TypeError: 'NoneType' object is not iterable**
>>> values
>>> deck=['%s of %s'%(v,s)for v in list(range(1,11)).extend('Jack Queen King'.split(' ')) for s in 'diamonds clubs hearts spades'.split(' ')]
Traceback (most recent call last):
  File "<pyshell#44>", line 1, in <module>
    deck=['%s of %s'%(v,s)for v in list(range(1,11)).extend('Jack Queen King'.split(' ')) for s in 'diamonds clubs hearts spades'.split(' ')]
**TypeError: 'NoneType' object is not iterable**
>>> list3=list1
>>> list3
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ['Jack', 'Queen', 'King'], 'Jack', 'Queen', 'King']
>>> 'diamonds clubs hearts spades'.split(' ')
['diamonds', 'clubs', 'hearts', 'spades']
>>> deck1=[v for v in values]
Traceback (most recent call last):
  File "<pyshell#48>", line 1, in <module>
    deck1=[v for v in values]
**TypeError: 'NoneType' object is not iterable**

解决后的代码

>>> values=list(range(1,11))
>>> values
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> values.extend('Jack Queen King'.split(' '))#代码主要更改的部分
>>> values
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King']
>>> suits='diamonds clubs hearts spades'.split(' ')
>>> suits
['diamonds', 'clubs', 'hearts', 'spades']
deck=['%s of %s'%(v,s)for v in values for s in suits]
>>> deck
['1 of diamonds', '1 of clubs', '1 of hearts', '1 of spades', '2 of diamonds', '2 of clubs', '2 of hearts', '2 of spades', '3 of diamonds', '3 of clubs', '3 of hearts', '3 of spades', '4 of diamonds', '4 of clubs', '4 of hearts', '4 of spades', '5 of diamonds', '5 of clubs', '5 of hearts', '5 of spades', '6 of diamonds', '6 of clubs', '6 of hearts', '6 of spades', '7 of diamonds', '7 of clubs', '7 of hearts', '7 of spades', '8 of diamonds', '8 of clubs', '8 of hearts', '8 of spades', '9 of diamonds', '9 of clubs', '9 of hearts', '9 of spades', '10 of diamonds', '10 of clubs', '10 of hearts', '10 of spades', 'Jack of diamonds', 'Jack of clubs', 'Jack of hearts', 'Jack of spades', 'Queen of diamonds', 'Queen of clubs', 'Queen of hearts', 'Queen of spades', 'King of diamonds', 'King of clubs', 'King of hearts', 'King of spades']

https://www.cnblogs.com/qquan/articles/4364990.html