문제

I am trying to do conditional processing according to when we are at the last item in a range, for example:

for i in range(intNumberOfPlayers):            
        #If we are on the last item in the range, do this...
도움이 되었습니까?

해결책

for i in range(intNumberOfPlayers):
    if i == intNumberOfPlayers - 1:
        print(i) #print last item

Ranges are not inclusive, so the last item is intNumberOfPlayers - 1

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top