I need Output like this
data = ['Orange', 'Oracle', 'Oraora', 'Oregon', 'Or', 'Origin']
input : Or
output : Orange
Oracle
Oraora
Oregon
Or
Origin
input : Ora
output : Orange
Oracle
Oraora
input : Ori
output : Origin
Try this solution
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
word_input = input()
word_list = [...]
for word in word_list:
if similar(word_input, word) >= 0.5:
print(word)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.