0

Range(20) starts from 0 or 1?

30th Oct 2021, 2:43 AM
Neethu Nath
Neethu Nath - avatar
5 Réponses
+ 7
Just adding to the answer, there's a complete documentation of range here. https://docs.python.org/3/library/stdtypes.html#typesseq-range '... If the start argument is omitted, it defaults to 0. '
30th Oct 2021, 3:02 AM
Hatsy Rei
Hatsy Rei - avatar
30th Oct 2021, 3:13 AM
Neethu Nath
Neethu Nath - avatar
+ 1
range(start, stop, step) range(20) means = range(0, 20, 1) It start from 0 and ends at 19. You can run this code↓ for i in range(20): print(i) Output: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
30th Oct 2021, 10:51 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
+ 1
Starts from 0 and it will print up to 19 0 to 19 means 20 numbers are printing in a given range
30th Oct 2021, 6:12 PM
sree harsha
sree harsha - avatar
- 1
Why don't you check it by yourself ??
30th Oct 2021, 9:31 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar