Answers for "character assignment in python"

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
3

how to create a string in python

var1 = "A String"
Posted by: Guest on March-08-2020

Code answers related to "character assignment in python"

Python Answers by Framework

Browse Popular Code Answers by Language