0

I am executing a code with SequenceMatcher (Difflib library) nested in an "IF" Statement like this:

'''

from difflib import SequenceMatcher

string_one = 'He is right'
string_two = 'He was right'

print("It returns a ratio", SequenceMatcher(a=string_one,b=string_two).ratio())
if(SequenceMatcher(a=string_one,b=string_two).ratio()>=60):
    print("It does not return a ratio", SequenceMatcher(a=string_one,b=string_two).ratio())

'''

The first Sequence Matcher (Before the If statement) returns a ratio, but the second one (Inside the "If" Statement) does not return a ratio.

Can any

2
  • The result of the .ratio() method is about 0.9 with your two strings. This is not greater than or equal to 60, so the if statement body does not execute. Commented Aug 11, 2022 at 14:21
  • Oh man I am tired, I did not realize it. I have been wondering about it for hours. Thank you Commented Aug 11, 2022 at 14:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.