Python Prg Ms
Python Prg Ms
For while
text = input("Enter a string: ") text = input("Enter a string: ")
vowels = "aeiouAEIOU" vowels = "aeiouAEIOU"
count = 0 count = 0
i=0
for char in text:
if char in vowels: while i < len(text):
count += 1 if text[i] in vowels:
count += 1
print("Number of vowels:", count) i += 1
****************************
print("Number of vowels:", count)
text = input("Enter a string: ")
count = 0
i=0
is_palindrome = True
Using list
text = input("Enter a string: ")
if text == text[::-1]:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
if text_list == reversed_list:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")