String Op
String Op
String Op
def longest_length(split_value):
max1=len(split_value)
a=split_value[0]
def word_count(str):
counts = dict()
words = split_value
def Substring_index():
count1=0
count2=0
str2=str(input("Enter the required string\n"))
for i in str2:
count1+=1 #Calculating length of initial string
key=str(input("Enter the substring\n"))
for j in key:
count2+=1 #Calculating length of substring/key
var1=0
for x in range(count1): #Iterate through length of original string
b=str2[var1:count2] #Slice every part of original string in pieces of length of substring
var1+=1
count2+=1
if(b==key): #Compare with key
print(x) #Return index
break
Substring_index()
def is_palindrome(s):
return s==s[::-1]
if ans:
print("Yes the given word is a palindrome.")
else:
print("The given string is not a palindrome.")
Output:
Enter the string: Mary had a little lamb
['mary', 'had', 'a', 'little', 'lamb']
The word with the longest length is: little and length is 6
{'mary': 1, 'had': 1, 'a': 1, 'little': 1, 'lamb': 1}
Enter the character: t
The character t has occured 2 times in the string.
Enter the required string
rainbow has seven colors
Enter the substring
rainbow
0
Enter a word: malayalam
Yes the given word is a palindrome.