Computer Science, asked by siddharthgager30, 7 months ago

write a program that reads a string and then print it a follows:-
input string:- this is a pen
output string :- uijt$jt$jtb$b$qfo

in ( python language) please​

Answers

Answered by anindyaadhikari13
4

\star\:\:\:\sf\large\underline\blue{Question:-}

write a program that reads a string and then print it a follows:-

input string:- this is a pen

output string :- uijt$jt $b$qfo

\star\:\:\:\sf\large\underline\blue{Logic:-}

Character after t = u

Character after h = i

Character after i = j

Character after s = t

Now, space is replaced by dollar.

We shall use this logic to solve the problem.

Now, a problem arises,

If the character is z then the next character '~' will be printed.

We can replace ~ with a.

\star\:\:\:\sf\large\underline\blue{Source\:Code:-}

s=input("Enter a String")

l=len(s)

for j in range (0,l):

if(s[j]==' ')

s[j]='$'

elif (s[j]=='z')

s[j]='a'

elif (s[j]=='Z')

s[j]='A'

elif (s[j]>='a' and s[j]<'z' and s[j]>='A' and s[j]<'Z')

s[j] = ord(s[j])+1

print(s)

Similar questions