Darkbule37
2021-01-26 20:16Python indexerror
5这是我的编码:
def cookie_cook2(cook):
""" cookie_cook2 takes a string `cook` and returns a string containing a grammatically correct and important question about the cook """
# code here.
if cook[0].lower()=="a" or cook[0].lower()=="e" or cook[0].lower()=="i" or cook[0].lower()=="o" or cook[0].lower()=="u":
return 'How many cookies could an '+ cook + ' cook if a good cook could cook cookies'
else:
return 'How many cookies could a ' +cook+ ' cook if a good cook could cook cookies'
但是如何我输入>>> print(cookie_cook2(""))
它产生额结果不是How many cookies could a cook if a good cook could cook cookies 而是Your submission raised an exception of type IndexError
.
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- 这个问题应该怎么修改代码呢?
- python
- 2个回答
- 出现list index out of range错误如何解决?
- python
- 2个回答
- python复制改的别人代码,IndexError: list index out of range报错,实在找不到根源在哪儿
- python
- 2个回答
- python 'if __name__ == "__main__":' 错误,直接执行测试(Terminal 运行正常)
- python
- 机器学习
- tensorflow
- 4个回答
- python的NameError: name 'xx‘ is not defined该怎么解决?
- python
- 1个回答
换一换