0

Why this pyrhon code stops counting at 2009 and not at 2010?

ans = list(range(1980, 2010)) max_ans = len(ans) print(max_ans) counter = 0 while counter <= max_ans - 1: an = ans[counter] print (an) counter = counter + 1

3rd May 2019, 5:57 AM
Youness El Mesmoudi
Youness El Mesmoudi - avatar
2 ответов
+ 6
That's how range() works. range(a, b) goes from a to b-1.
3rd May 2019, 6:03 AM
Anna
Anna - avatar
+ 2
Thanks for your quick answer 😊
3rd May 2019, 7:03 AM
Youness El Mesmoudi
Youness El Mesmoudi - avatar