Can someone please explain range(len(insert something here))?


#1

The section I am in (list and functions) uses the term range(len(insert something here)) alot. I have been trying to figure it out and it don't understand it. Can someone please explain? Thanks!


#2

len gives you the length of a string. Such as len("Hello") will store it as 5. and if you print len("Hello") it will print 5.


#3

what does the range part do?


#4

Range gives you a range of numbers, starting with the first argument, ending with the number before the last argument.

Some ranges:

range(2, 8) #[2, 3, 4, 5, 6, 7]
range(0, 2) #[0, 1]
range(-1, 4) #[-1, 0, 1, 2, 3]

You can also use an optional step argument.