python program with string
python program with string
# Initialize count to 0
vowel_count = 0
vowels = "aeiouAEIOU"
# Count vowels
for char in string:
if char in vowels:
vowel_count += 1
def reverse_string(text):
return text[::-1]
reversed_text = reverse_string(user_input)
def is_palindrome(text):
return text == text[::-1]
if is_palindrome(user_input):
print("The string", user_input, "is a palindrome.")
else:
print("The string", user_input, "is not a palindrome.")
def to_title_case(s):
return s.title()
# Example
result = to_title_case(text)
# Example
return s.count(char)
# Example
text = "banana"
character = "a"
print("The character '" + character + "' appears", result, "times in '" + text + "'.")