To Reverse a string with out using for loop in python. | DAY 1

jagannath_ghantenavar_3e9

Jagannath Ghantenavar

Posted on July 30, 2024

To Reverse a string with out using for loop in python. | DAY 1

a = 'Dev.to'
a[::-1]

Explanation :

[start index : end index : step parameter ]

  • The first colon : indicates the start index (default is the beginning of the sequence).
  • The second colon : indicates the end index (default is the end of the sequence).
  • The third colon : indicates the step parameter, which means the sequence should be traversed in steps of -1 (i.e., in reverse)..
💖 💪 🙅 🚩
jagannath_ghantenavar_3e9
Jagannath Ghantenavar

Posted on July 30, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related