Looping is so SIMPLE!! #python #coding #programming #learnpython

Akansha Yadav walks through Python's range() function for loops. range(1,6) prints 1 through 5. Add a third argument to set the step: range(1,6,2) gives odd numbers 1,3,5.
Chapters
for i in range, and I'm giving it a range 1, 6, enter, print i. So here I am going to get 1 to 5 numbers. But suppose I don't want 1 to 5, I just want 1, 3, 5. It means odd number out of it. So what I can do is I can say for i in range 1, 6 print i. This is the normal code that I have written till now, but now I have to make some modification. I have to add steps as well. So in this case, it will print 3, 5, 1, 3, 5 for me because it's starting from 1, going up to 6, and skipping 2 numbers. By default, in this case, it was 1. So suppose I'm entering 1, I will get the same output because by default the value is 1. It is skipping 1 numbers and printing 1, 2, 3, 4, 5. For you. But in case you wanted to print odd numbers, I am writing 1, 3, 5. Suppose I want even numbers, so I can say for i in range . So let's start from 0 because I want 2. So in this case also, I'm going to use print. 0 to 4, which is even numbers. So this is how your range function works. There are two types of range functions. One is with the start and end. Another one is with the start comma end comma step. So these are the two formats of range functions that you can use. If










