thanks, but what is wrong if i use swapcase() function (PYTH 3.6)?
Also, i used various methods for counting like set() + count() and dict.get() but they all come in curvy bracket thingys ( ‘{ }’ ) while the required output does not
Did you write a code? It would be much help
I’m sorry but I usually code in Java, so I might not be able to code in Python for this … and I’ve just now built up the logic and haven’t coded it yet 
okay no problem…do tell me when you are done tho…thanks 
Also. whats wrong with this approach:
def split(word):
return list(word)
for _ in range(int(input())):
N = int(input())
r,L = map(int , input().split())
S = input()
SS = S.swapcase()
x = split(SS)
for i in range(len(x)):
if(x[i].isupper()):
x[i] = chr(ord(x[i]) - L)
else:
x[i] = chr(ord(x[i]) + r)
listToStr = ' '.join(map(str, x))
print(listToStr)
res = {}
for keys in x:
res[keys] = res.get(keys, 0) + 1
#print(str(res))
i am getting the required output’s first line, i.e, kLfGc… but as separate characters and not one single word (k L f G c…)
And my count is coming as {k : ‘2’} instead of k 2
i clicked it by mistake and was not able to remove it

fixed
Also, can you format your code so I can run it myself?
def split(word):
return list(word)
for _ in range(int(input())):
N = int(input())
r,L = map(int , input().split())
S = input()
SS = S.swapcase()
#print(SS)
x = split(SS)
for i in range(len(x)):
if(x[i].isupper()):
x[i] = chr(ord(x[i]) - L)
else:
x[i] = chr(ord(x[i]) + r)
listToStr = ' '.join(map(str, x))
print(listToStr)
res = {}
for keys in x:
res[keys] = res.get(keys, 0) + 1
#print(str(res))
Well… one issue is that you have x = split(SS)
when I guess you want x = SS.split()
(which defaults to splitting by spaces)
def split(word):
return list(word)
for _ in range(int(input())):
N = int(input())
r, L = map(int, input().split())
S = input()
SS = S.swapcase()
# print(SS)
x = split(SS)
for i in range(len(x)):
if x[i]==' ':
continue
if (x[i].isupper()):
x[i] = chr(ord(x[i]) - L)
else:
x[i] = chr(ord(x[i]) + r)
listToStr = ''.join(map(str, x))
print(listToStr)
res = {}
for keys in x:
if keys==' ':
continue
res[keys] = res.get(keys, 0) + 1
for i in res:
print(i,res[i],end=" ")
print()
This would give output in desired format.
The checker for this problem seems to be incorrect.
1 Like
thank you…it seems to be working on Command Prompt
Lemme submit it and see
It doesn’t. I’ve checked.
oh…
I noticed that though first line of output is correct, the order of the second line is wrong (according to example test case)… could that be the reason?
1 Like
Yeah maybe…the author must have not used a custom judge to verify that thing. There could be multiple outputs.
1 Like
I just noticed that the example test case prints the count in alphabetical order, while your code prints it according to appearance of character in string
Required output =
G 1 K 1 L 1 M 1 Q 1 R 1 S 1 W 2 c 1 e 1 f 1 k 2 p 1 t 1
Your output =
k 2 e 1 S 1 f 1 Q 1 K 1 L 1 c 1 t 1 G 1 R 1 W 2 p 1 M 1
^^^ this is not even order of appearance…how would one fix this?
1 Like
It noticed the same now…you may try to print in that particular order (though the statement should have mentioned this thing).
1 Like
AC Sol
you can sort the keys in dictionary and it will print the desired output.
1 Like
could you explain how…I am a not very experienced in coding

1 Like