Answers for "python set char at"

2

how to add char to string python

def addChar(text,char,place):
  return text[:place] + char + text[place:]
Posted by: Guest on May-10-2020
5

python char at

>>> s = "python"
>>> s[3]
'h'
>>> s[6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[0]
'p'
>>> s[-1]
'n'
>>> s[-6]
'p'
>>> s[-7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>>
Posted by: Guest on March-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language