I have two strings:
StringA = "SushantSingh"
StringB = "SinghRajput"
Desired resultant string is:
result = "SushantSinghRajput"
How to get the result string using some operations in python from StringA and StringB? A good/clean way. Basically sort of an OR Operation.
My attempt for others to view:
import difflib
StringA = "SushantSingh"
StringB = "SinghRajput"
res = ""
res_S = ""
res = [li[2] for li in difflib.ndiff(StringA,StringB)]
for ele in res:
res_S+=ele
print(res_S)
Out: 'SushantSinghRajput'
but I seek even less lines answer. more short version is:
import difflib
StringA = "SushantSingh"
StringB = "SinghRajput"
res = ''.join([li[2] for li in difflib.ndiff(StringA,StringB)])
print(res)
any other better way without using difflib ?