on-internet
← Community

How to highlight the differences between two strings in Python?

Stack Overflow ·

I want to highlight the differences between two strings in a colour using Python code. Example 1: sentence1 = "I'm enjoying the summer breeze on the beach while I do some pilates." sentence2 = "I am enjoying the summer breeze on the beach while I am doing some pilates." Expected result (the part marked by asterisks should be in red): I *am* enjoying the summer breeze on the beach while I *am doing* some pilates. Example 2: sentence1: "My favourite season is Autumn while my sister's favourite season is Winter." sentence2: "My favourite season is Autumn, while my sister's favourite season is Win

Comments

Sign in or sign up to comment and upvote.

No comments yet.