For example:
def contain():
score = 4
if score in num:
return True,score;
num = [1,2,3,0]
iscontain,score = contain()
print iscontain,score
Results:
>>>
Traceback (most recent call last):
File "D:\Program Files\python\chengxu\temp.py", line 8, in <module>
iscontain,score = contain()
TypeError: 'NoneType' object is not iterable</span>
>>>
Note: When there is only an if condition and multiple variables are returned, an exception will occur if the if condition is not satisfied
Solution: Add an else statement
def contain():
score = 4
if score in num:
return True,score;
else:
return False,score;
num = [1,2,3,0]
iscontain,score = contain()
print iscontain,score
Results:
>>>
False 4
Reference article:
http://blog.csdn.net/dataspark/article/details/9953225
Read More:
- TypeError: ‘numpy.int64′ object is not iterable ,’int’ object is not iterable
- TypeError: ‘int’ object is not iterable
- Python custom class typeerror: ‘module’ object is not callable
- Python 3 error typeerror: ‘dict’_ keys‘ object is not subscriptable
- Python error prompt: typeerror: ‘builtin’_ function_ or_ method‘ object is not subscriptable
- Python error: typeerror: ‘module’ object is not callable
- Python error: typeerror: ‘Int’ object is not subscriptable
- Python error: typeerror: ‘Int’ object is not subscribable
- Python reported error: typeerror:’int’object is not subscriptable
- Uncaught (in promise) TypeError: Object(…) is not a function
- Vue error in mounted hook: “typeerror: object (…) is not a function“
- Typeerror: ‘module’ object is not callable
- TypeError: this.getOptions is not a function at Object.lessLoader
- new_lrs[:5] = lr_warm [12] TypeError: can only assign an iterable
- Type error: cannot unpack non Iterable non type object appears when starting Bert server in Ubuntu system
- AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- AttributeError: ‘NoneType‘ object has no attribute ‘shape‘
- Typeerror in gitbook init: cb.apply is not a function solution