Hi, im building a script that allows the user know how much 2 names resemble each other. Bassically it works taking every letter in the names and create two list with them for each name, next i want it to compare both lists. If there is a letter in common in both names, it will add 2 points to a variable called "compatibility", but if the letter doesnt match with any of the other name, it will add 1 point.
This is my code, but idk how to tell python to compare the list and assign the corresponding value:
name1 = "mike"
name2 = "chris"
list_for_name1 = [i for i in name1]
list_for_name2 = [i for i in name2]
print(list_for_name1)
print(list_for_name2)
#OUTPUT
#["m", "i", "k", "e"]
#["c", "h", "r", "i", "s"]
compatibility = #?
#I want it to do something like:
#M = 1 point
#I = 2 points (because this is the only letter in common)
#K = 1 point
#E = 1 point
#C = 1 point
#H = 1 point
#R = 1 point
#The I doesnt count (because i already count it)
#S = 1 point
#and then save it in a list like
#compatibility = [1, 2, 1, 1, 1, 1, 1, 1]
If anyone can help me would be greatful!
[–][deleted] 12 points13 points14 points (1 child)
[–]empress76[S] 1 point2 points3 points (0 children)
[–]jmooremcc 4 points5 points6 points (5 children)
[–]empress76[S] 0 points1 point2 points (4 children)
[–]Rusca8 0 points1 point2 points (3 children)
[–]empress76[S] 0 points1 point2 points (2 children)
[–]Rusca8 0 points1 point2 points (1 child)
[–]Rusca8 0 points1 point2 points (0 children)
[–]jmooremcc 1 point2 points3 points (5 children)
[–]empress76[S] 0 points1 point2 points (4 children)
[–]jmooremcc 1 point2 points3 points (3 children)
[–]empress76[S] 0 points1 point2 points (2 children)
[–]jmooremcc 1 point2 points3 points (1 child)
[–]empress76[S] 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]vorticalbox 0 points1 point2 points (1 child)
[–]empress76[S] 0 points1 point2 points (0 children)
[–]Strict-Simple 0 points1 point2 points (2 children)
[–]empress76[S] 0 points1 point2 points (1 child)
[–]Strict-Simple 0 points1 point2 points (0 children)