Answers for "get char of string 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
1

char in python

there is no dataype as char in python
Posted by: Guest on March-26-2021
0

get char of string python

string[index]
Posted by: Guest on August-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language