substring = lambda s,start=0,end=len(s) : s[start:end]
print(substring("python",1))
我收到一条错误消息,说未定义s
NameError Traceback (most recent call last)
<ipython-input-18-7e4b2c9c6d67> in <module>()
----> 1 substring = lambda s,start=0,end=len(s) : s[start:end]
2 print(substring("python",1,3))
NameError: name 's' is not defined
我想将开始和结束作为可选变量。我该怎么办?