calculate the difference between “nl10107” and “nl10318”. in python

You can convert the alphanumeric values to integers and then subtract them to get the difference. Here's how you can do it:

main.py
s1 = "nl10107"
s2 = "nl10318"

num1 = int(s1[2:])  # extracting the integer value from the string
num2 = int(s2[2:])

diff = num2 - num1
print(diff)
149 chars
9 lines

This will output:

main.py
211
4 chars
2 lines

So the difference between nl10107 and nl10318 is 211.

related categories

gistlibby LogSnag