Darkbule37
Darkbule37
2021-01-26 20:16

Python indexerror

5
  • python

这是我的编码:

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条回答