I'm new to python and trying to write a program to compare strings; specifically the characters in sequence in each string and the decimal ASCII values of these characters.
For example, I have string 1 'abcd1234' and string 2 'bcde2345'
In ASCII decimal this would be 97,99,101,103,53,55,57,59 and 97,98,99,100,49,50,51,52
I want to find the difference in the decimal number of each character in sequence and be able to apply this decimal difference to a new string to shift its characters.
So far I have following:
str1 = 'abcd1234'
str2 = 'bcde2345'
str3 = '7:69h5i>'
tem = {55,58,54,57,104,53,105,62} # just a test to see if I could use a set
print(str1)
for i in str1:
print(ord(i))
print('\n')
print(str2)
for i in str2:
print(ord(i))
print('\n')
print(str3)
for i in str3:
print(ord(i))
print('\n')
i = 0
print(tem)
for i in tem:
print(chr(i))
I thought I could do it using a set but the characters are re-arranged somehow when I do print of them.
I'm sure there's an easy way of achieving what I'm after!