Can someone please debug this

a = input()
s = list(a)
for i in range(0,len(s)-1,2):
s[i],s[i+1]=s[i+1],s[i]
q = “”.join(s)
f =
for l in q:
t = ord(l)
e = 97+122-t
r = chr(e)
f.append(r)
m = “”.join(f)
print(m)

Well, there are some syntax error with your code, can you try below code, I hope it can fix the error you are getting.

a = input()
s = list(a)

# Swap adjacent characters
for i in range(0, len(s)-1, 2):
    s[i], s[i+1] = s[i+1], s[i]

# Initialize an empty list 'f'
f = []

# Perform character transformation
for l in s:
    t = ord(l)
    e = 97 + 122 - t
    r = chr(e)
    f.append(r)

# Join the transformed characters
m = "".join(f)
print(m)

Thanks

1 Like