alexa

What is 'eovdedn' doing in this function in python ?

What is 'eovdedn' doing in this function in python ?

num %2 returns False or True, which can be understood as 0 or 1.

Using the slicing notation 'eovdedn'[num % 2::2] we can have the following results:

  • If num % 2 equals False (0) :
    'eovdedn'[0::2] = even (returns every 2 characters starting from 0)

  • If num % 2 equals True (1) :
    'eovdedn'[1::2] = odd (returns every 2 characters starting from 1)


207 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry