ter In Decrypted StringEvery character in the input string is followed by its frequency.Write a function to decrypt the string and find the nth character of thedecrypted string. If no character exists at that position then return "-1".For eg:- if the input string is "a2b3" the decrypted string is "aabbb".Note: The frequency of encrypted string cannot be greater than a singledigit i.e < 10.Input Specification:input1: a stringinput2: n, the position of the character starting from 1Output Specification:II
Answers
Answered by
0
Answer:
Python
def descrept_str(string,n):
st=''
for i in range(0,len(string),2):
st+=string[i]*int(string[i+1])
if len(st)>=n:
return st[n-1]
return -1
Explanation:
1. first decrypt the string
2. then from string find out nth character.
Similar questions