title: Difference between slicing vs indexing when index position is unknown
body: <p>When an index position is unknown, is it better to use slicing rather than indexing as indexing returns out of range error?</p>
  
  <pre><code>from random import randint
  
  __index__ = randint(0, 100)
  print(__index__)
  
  key = "Some random string which comes on our way and we don't find the length"
  
  ''' Slicing is better when unknown length of a string?''' 
  x = key[__index__:__index__+1]
  if x is '':
      print("No value in slicing")
  else:
      print("Sliced value %s" % (x))
  
  ''' Indexing runs into IndexError: string index out of range when out of range'''
  x = key[__index__]
  if x is None:
      print("No value in indexing")
  else:
      print("Indexed value %s" % (x))
  </code></pre>
  
  <p>When the random index is out of range, then it errors out in indexing. Is it better to use slicing in this case?</p>
  
  <pre><code>$ python main.py
  98
  No value in slicing
  Traceback (most recent call last):
    File "main.py", line 15, in &lt;module&gt;
      x = key[__index__]
  IndexError: string index out of range
  </code></pre>