Sunday, December 16, 2018

Python Ninja Bootcamp 36-Enumerate function

Learn Python like a Professional! Take You from 0 to Hero






In this Python lecture, we will learn about the Enumerate( ).

"Enumerate is the function that takes a sequence as a parameter & adds a counter to elements, returns it in a form of enumerate object ".

Python Enumerate function

Let's see the some example

tuple(enumerate([1,2,3,4,5]))
>> ((0, 1), (1, 2), (2, 3), (3, 4), (4, 5))

In this example, the list elements get paired along with counter

for count,value in enumerate((1,2,3,4,5)):
    if count>2:
        print(value)
>>4
    5

In this example, a counter is used to print the element of the tuple.



EDITS ARE WELCOMED!!

In the next Blog, we will discuss all() & any()  

https://sngurukuls247.blogspot.com/2018/12/python-ninja-bootcamp-37-all-any.html

......................................................................................................................................

Follow the link below to access Free Python Lectures-
https://www.youtube.com/channel/UCENc9qI7_r8KMf6-_1R1xnw

Instagram-
https://www.instagram.com/python.india/

View the Jupyter Notebook for this lecture

Download the Jupyter Notebook for this lecture 



Feel free contact me on-
Email - sn.gurukul24.7uk@gmail.com

No comments:

Post a Comment