search
Wednesday, August 7, 2019
Python program to find the longest common sub-string from two given strings
from difflib import SequenceMatcher
a=input('enter first string : ')
b=input('enter second string : ')
c = SequenceMatcher(None,a,b)
match = c.find_longest_match(0, len(a), 0, len(b))
if (match.size!=0):
print(a[match.a: match.a + match.size])
else:
print('Longest common sub-string not present')
a=input('enter first string : ')
b=input('enter second string : ')
c = SequenceMatcher(None,a,b)
match = c.find_longest_match(0, len(a), 0, len(b))
if (match.size!=0):
print(a[match.a: match.a + match.size])
else:
print('Longest common sub-string not present')
Python program to find the first non-repeating character in given string
a = input('Enter a string : ')
char_order = []
ctr = {}
for c in a:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
print(c)
break
char_order = []
ctr = {}
for c in a:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
print(c)
break
Subscribe to:
Posts (Atom)
Python program to create a string from two given strings concatenating uncommon characters of the said strings
PROGRAM : a = input('Enter a string : ') b = input('Enter a string : ') c='' for i in a: if(i not in b):...
-
a = input('Enter a string ') c=len(a) d=a[1:(c-1)] print(d) d = a[c-1]+d+a[0] print(d)
-
a = input('Enter a string ') b=a c=d=0 c = a.find('not') d = a.find('poor') print(c,d) if(c>=0 and d>=0...
-
PROGRAM: a = input('Enter a string : ') dict = {} c='' d='' a=a.rstrip() for i in a: keys = dict.keys()...