string indexing:-using idle
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> string="believer"
>>> first_string[0]
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
first_string[0]
NameError: name 'first_string' is not defined
>>> first_string="believer"
>>> first_string[0]
'b'
>>> first string[-1]
SyntaxError: invalid syntax
>>> first_string[-1]
'r'
>>>
Comments
Post a Comment