Jun 4, 2023

Python #5 (Indexing)


Indexing

item[start:stop:stepover]

item = 'abcdefgh'
print(item[0:3])
print(item[3:])
print(item[:3])
print(item[0:6:2])
print(item[::-1])
>>

abc defgh abc ace hgfedcba

Count, Replace, Capitalize, Upper, Lower

item = 'a a b c b a f g e h i i c b c e d'
print(item.capitalize())
print(item.upper())
print(item.count('b'))
item = item.replace('b', 'a')
print(item.count('a'))