【发布时间】:2022-12-07 23:46:43
【问题描述】:
我是 python 的新手,我正在尝试从用户那里获取值列表并在函数中使用它们,这是我的代码:
def functionwithList(*words):
for i in words:
print(f"this is part of the words list: {i}")
param1,param2 = functionwithList(input('enter two numbers').split())
当我执行代码时,我得到以下输出以及 Cannot unpack non-iterable NoneType Object
enter two numbers1 2
this is part of the words list: ['1', '2']
Traceback (most recent call last):
File "I:\DataScience_BootCamp\PythonBootcampSession2\Demo\Session_4.py", line 16, in <module>
param1,param2 = functionwithList(input('enter two numbers').split())
TypeError: cannot unpack non-iterable NoneType object
有人可以解释这里有什么问题吗?
【问题讨论】:
-
你期望
functionwithList返回什么?
标签: python