Problem with code

what is problem with the code

n = int(input())
l = []
for i in range(n):
x = input()
l.append(x)

def anagrams(l):
d = {}

for s in l:
	s1 = sorted(s)
	s = "".join(s1)
	if (s not in d.keys()):
		d[s] = []

for s in l:
	s1 = sorted(s)
	s2 = "".join(s1)
	d[s2].append(s)


for i in d:
	d[i] = " ".join(d[i])
	print(d[i])

anagrams(l)

failing some test cases

@Tejas123 please share your code by saving it on cb ide

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.