22
loading...
This website collects cookies to deliver better user experience
prefix: to check that the string starts
start = 0: the starting index where the giving prefix is needed to be checked.
end = len(str) - 1: the ending index where the giving needs to be checked.
phone_number = '+212123456789';
print(phone_number.startswith('34',1)) # False
print(phone_number.startswith('+212')) # True
print(phone_number.startswith('56', 8)) # True
print(phone_number.startswith('78', 10, 12)) # True
country_code = '212'
user_phone_number = f'{country_code}6123452129'
# 2126123452129
print(user_phone_number)
# 066123452129
print(user_phone_number.replace(country_code, '06', 1))
article_slug = '5-html-tags-that-almost-nobody-knows'
article_title = article_slug.replace('-',' ').title()
# 5 HTML Tags That Almost Nobody Knows
print(article_title)
full_name = 'Aya Bouchiha'
print(full_name.upper()) # AYA BOUCHIHA
print(full_name.lower()) # aya bouchiha
message = 'Tanger is a beautiful city'
address = 'Tanger, Morocco'
language = 'en-us'
print(message.find('beautiful')) # 12
print(address.find('Morocco', len(address) - 7)) # 8
print(language.find('en', 0, 2)) # 0
print(language.find('fr', 0, 2)) # -1