Professional Documents
Culture Documents
def my_function(x):
return x[::-1]
print(mytxt)
OUTPUT
print(str(Str1)[::-1])
OUTPUT
enter a string:hello
olleh
PALINDROME
def isPalindrome(s):
return s == s[::-1]
ans = isPalindrome(s)
if ans:
print("Yes")
else:
print("No")
COUNT OF STRING
count = 0
for i in test_str:
if i == 'E':
count = count + 1
OUTPUT
Count of string : 2
REPLACING CHARACTERS
METHOD 1:
x = txt.replace("bananas", "apples")
print(x)
OUTPUT:
I like apples
METHOD 2:
print(string.replace("E", "a"))
OUTPUT