0% found this document useful (0 votes)
1 views

Practice assignment on strings

Uploaded by

ajking8972
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Practice assignment on strings

Uploaded by

ajking8972
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#Write functions tocount the number of common characters in both the strings and list

the common characters in the following different situations


#1. case sensitive matching and not counting duplicate occurrences of characters in
string 1
"""def common_chars_not_duplicate_case_sensitive_check(string1,string2):
matched=[]
sorted=[]
count=0

for i in string1:
if i in string2 and i not in matched :
sorted.append(i)
matched.append(i)
count=count+1
return count, sorted
a=common_chars_not_duplicate_case_sensitive_check("Ankita","Ajay")
print(a)"""

#2. ignoring case matching and counting duplicate occurrences of characters in string
1
#Write a program to read two strings and call the above functions by passing strings
as parameters.
#upload the code and the output
"""def common_chars_duplicate_also_ignore_case_sensitive(string1,string2):
sorted=[]
count=0
s1=string1.lower()
s2=string2.lower()
for i in s1:
if i in s2 :
sorted.append(i)

count=count+1
return count, sorted
a=common_chars_duplicate_also_ignore_case_sensitive("Ankita","Ajay")
print(a)"""

You might also like