+ 1

Why my Jungle Camping code is failed in 3rd test?? Plz help

noise=str(input()) noise1=noise.split() animals={'Lion':'Grr','Tiger':'Rawr','Snake':'Ssss','Birds':'Chirp'} m=[] for a in animals: for k in noise1: if animals[a]==k: m.append(a) else: continue j=' '.join(m) print(j)

7th Aug 2020, 3:14 PM
Jayendra Todawat
Jayendra Todawat - avatar
4 ответов
+ 2
Almost... I was wrong suggesting, it would not allow repeating them, in fact in does, but you are rearranging them then! 😉 e.g. for [Lion: Gr, Bird: Chirp] you will output Lion Lion -> Gr Gr, but Lion Bird Lion -> Gr Gr Chirp.
7th Aug 2020, 3:22 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Sandra Meyer Plz suggest me any changes in it..!!!
7th Aug 2020, 3:46 PM
Jayendra Todawat
Jayendra Todawat - avatar
+ 1
I'm almost sure, it is your outer loop. Your code does not allow, that an animal is repeated after another one!
7th Aug 2020, 3:20 PM
Sandra Meyer
Sandra Meyer - avatar
0
You don't need the outer loop at all! Iterate over the noises only, not over the animals. Replace each noise with an animal name...
7th Aug 2020, 3:54 PM
Sandra Meyer
Sandra Meyer - avatar