0

In this code:

word='pardis'
print(len(word[1:]))

the output is 5. I also try this code for some other words and I find out that the output is length of word minus 1. My question is what is [1:] meaning and what it does? I am unfamiliar with it. I guess It is the reason that output is length minus 1

SiHa
  • 7,830
  • 13
  • 34
  • 43
hgs
  • 141
  • 7
  • 1
    You say you still don't know the answer. Did you visit the linked duplicate? You will find all the answers there. – SiHa May 20 '20 at 11:39
  • yes I visited that and I didnt see anything like a[1:] – hgs May 20 '20 at 11:41
  • 1
    Really? The accepted answer has `a[start:]` what do you think that means? If you're still not sure, then the best thing to do is write some test code. Play with different slices (`[:]` is slice notation), and see what they do. It can be confusing at first, but it's really very simple. – SiHa May 20 '20 at 11:52
  • Ok Thanks, maybe I should improve my English langue to understand better. – hgs May 20 '20 at 11:54
  • 1
    Good luck - enjoy your Python – SiHa May 20 '20 at 11:57

0 Answers0