Hi I am trying to code which get two names as input and remove common letters between those strings(literally for calculating flames)
`
""" For testing purpose default names were set
name1=‘ramesh’
name2=‘suresh’"""
""“Get the names for finding relationship”""
name1=input(‘Enter the name of person 1 : ’)
name2=input(‘Enter the name of person 2 : ’)
""“To show the names entered”""
print(name1)
print(name2)
""“To remove whitespaces in entered names”":
purename1=name1.replace(“ ”, "")
purename2=name2.replace(“ ”, "")
""“ To convert uppercase characters to lowercase characters”""
purename1=purename1.lower()
purename2=purename2.lower()
""“To typecast string to list”""
purename1list=list(purename1)
purename2list=list(purename2)
""“To sort the characters in lists”""
purename1list.sort()
purename2list.sort()
""“To find which name has low length”""
if len(purename1) < len(purename2):
list1=purename1list
list2=purename2list
elif len(purename1) > len(purename2):
list1=purename2list
list2=purename1list
else :
list1=purename1list
list2=purename2list
print(purename1list)
print(‘———————–’)
print(purename2list)
print(‘———————–’)
def relation(list11,list22):
for x in list11:
print(x)
if x in list22:
list22.remove(x)
list11.remove(x)
else :
pass
a=len(list11)
b=len(list22)
c=[a,b]
return c
""“To check whether all the input names are alphabets or not”""
a=purename1.isalpha()
b=purename2.isalpha()
if ( a & b == True ):
q=relation(list1,list2)
print(list1)
print(‘———————–’)
print(list2)
print(q)
pass
else:
pass
"""For future edit
try:
if f==True:
pass
except Exception:
print(“Oops! The entered characters must be alphabets : Try again…”)
else:
print(“This is else part”)"""
print(‘….ended….’) `
👆this is the code
Here I took two names and then I sorted it and typecast them to a list and then I passed it to the relation() [user defined function] to remove the common letters between two lists. I am not getting the expected output.
This is the output that I get 👇

Here ‘h’ is common to both the list but it didn’t get removed . Anyone help me to sort out this issue
@sibidharan @Thaya @AGS @Sudhakar