"""
Examples to show available string methods in python
"""

# Replace Method
a = "1abc2abc3abc4abc"
print(a.replace('abc', 'ABC', 1))
print(a.replace('abc', 'ABC', 2))

# Sub-Strings
# starting index is inclusive
# Ending index is exclusive
b = a[1]
print(b)
c = a[1:6]
print(c)
d = a[1:6:2]
print(d)

e = 'This is a string'
print(e)
print(e[:])
print(e[1:])
print(e[:6])
print(e[-1:])
print(e[-1])
print(e[:-1])
print(e[:len(e)])
print(e[::1])
print(e[::2])
# reverse string
print(e[::-1])
# cannot change the original string
e[1] = 'j'
# strings are immutable. You cannot change the memory allocation of a string. All changes are done at runtime.


fb3abeafd05fa9f733668aed3059e7dbc925851e
<mask token>

<mask token>
print(a.replace('abc', 'ABC', 1))
print(a.replace('abc', 'ABC', 2))
<mask token>
print(b)
<mask token>
print(c)
<mask token>
print(d)
<mask token>
print(e)
print(e[:])
print(e[1:])
print(e[:6])
print(e[-1:])
print(e[-1])
print(e[:-1])
print(e[:len(e)])
print(e[::1])
print(e[::2])
print(e[::-1])
<mask token>

<mask token>
a = '1abc2abc3abc4abc'
print(a.replace('abc', 'ABC', 1))
print(a.replace('abc', 'ABC', 2))
b = a[1]
print(b)
c = a[1:6]
print(c)
d = a[1:6:2]
print(d)
e = 'This is a string'
print(e)
print(e[:])
print(e[1:])
print(e[:6])
print(e[-1:])
print(e[-1])
print(e[:-1])
print(e[:len(e)])
print(e[::1])
print(e[::2])
print(e[::-1])
e[1] = 'j'

"""
Examples to show available string methods in python
"""

# Replace Method
a = "1abc2abc3abc4abc"
print(a.replace('abc', 'ABC', 1))
print(a.replace('abc', 'ABC', 2))

# Sub-Strings
# starting index is inclusive
# Ending index is exclusive
b = a[1]
print(b)
c = a[1:6]
print(c)
d = a[1:6:2]
print(d)

e = 'This is a string'
print(e)
print(e[:])
print(e[1:])
print(e[:6])
print(e[-1:])
print(e[-1])
print(e[:-1])
print(e[:len(e)])
print(e[::1])
print(e[::2])
# reverse string
print(e[::-1])
# cannot change the original string
e[1] = 'j'
# strings are immutable. You cannot change the memory allocation of a string. All changes are done at runtime.

