Find the string similarity between two strings

In this program, we will take two strings as input and  find the string similarity between two given strings

Steps to solve te program
  1. Take 2 strings as inputs.
  2. Import difflib library.
  3. From difflib library use SequenceMatcher to find the similarity between two strings.
  4. Print the output.
				
					#Input string
str1 = "Learning is fun in Sqatools"
str2 = "Sqatools Online Learning Platform"

import difflib
result =  difflib.SequenceMatcher(a=str1.lower(), b=str2.lower())

#Printing output
print(result.ratio())
				
			

Output :

				
					0.4
				
			

remove unwanted characters from a given string

extract numbers from a given string

Leave a Comment