开发者

Count, index out of range [closed]

开发者 https://www.devze.com 2023-02-26 10:39 出处:网络
It's difficult to tell what is being asked开发者_如何学编程 here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current for
It's difficult to tell what is being asked开发者_如何学编程 here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have this code to return a number but I get the error: IndexError: index out of range: 0 with the return.

nbus=1

users = []

for i in range(nb):

    ind = (int(nbus)-1)

ind= ind +1 

return users[ind]

Do you know why?

Thanks


You never append to users, therefore it contains no elements and has no valid indexes.

0

精彩评论

暂无评论...
验证码 换一张
取 消