Discussion Room : IDC101

Queries / doubts

Queries / doubts

द्वारा Dr. Amit Kulshrestha -
उत्तरों की संख्याः 1

In this thread you may directly post your queries/doubts/observations related to Python programming. I encourage everyone to participate.

My observation, that I made today only. See this.

s = "Python is great."
print s[::-1][::-1]

Has sometime tried it? Isn't it intriguing?


Dr. Amit Kulshrestha के जवाब में

Re: Queries / doubts

द्वारा Rutvik Kayastha -

As per my simple observations,

s = "Python is great."

  1. print s[2] = t ,print s[2][1] will be absured because "print s[2]" have only 1 char in output. so print s[2][0] will only work.
  2. print s[::-1]=.taerg si nohtyP ,print s[::-1][::-1] will do again do that operation on output so we will get original string inverted back.
  3. so, second bracket applies specified operation in it, on output of first bracket.

संलग्नक My work 1.JPG