Professional Documents
Culture Documents
Python For Oil and Gas: Website - Linkedin - Youtube
Python For Oil and Gas: Website - Linkedin - Youtube
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
var = 'Reservoir'
# R = 0, -9
# e = 1
# s = 2
# e = 3
# r = 4
# v = 5
# o = 6, -3
# i = 7, -2
# r = 8 , -1
# variable_name[index pos]
var[0]
'R'
var[2]
's'
var[-1]
'r'
var[8]
/
1/28/2021 Python for O&G Lecture 9 - String Indexing - Colaboratory
'r'
var[9]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-21-600d4ab32bb0> in <module>()
----> 1 var[9]
# length function
# syntax - len(variable_name)
len(var)
var2 = 'Thiruvanantapuram'
len(var2)
17
var2[16]
/
1/28/2021 Python for O&G Lecture 9 - String Indexing - Colaboratory
'm'
/
1/28/2021 Python for O&G Lecture 9 - String Indexing - Colaboratory