cover-img

#1 Python tricks for Beginners

Using the Range() function

28 July, 2021

17

17

0

🔨The Function: Range()

The range function creates a range of numbers on the fly for us. So we don't need to define a list before hand with a couple of numbers. The beauty of the function is that it's simple to use! Check it out👇
The range function takes 2 mandatory arguments and 1 optional. Here's an example of the function with the generated object:
range(0,20,2) [0,2,4,6,8,10,12,14,16,18]
Argument 1: '0'. This is the starting point of the range. Argument 2: '20'. This is the end point of the range. NOTE, the number 20 will not be included in the range! Argument 3: '2'. This is an optional argument. It will decide the 'steps'. So '2' adds 2 to every next generated number, starting at 0.
Let's check it out below

💻Code Snippet

python

17

17

0

python

Raza Zaidi
I'm the R in Python. IT Manager by day. Chief Python Officer by night. Now go and code some Python.

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.