jungle camping | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

jungle camping

I wrote following code in Python and 3 testcases have done but 2 testcase not. What's wrong of this code? https://code.sololearn.com/c6K710PX6waq/?ref=app

31st Dec 2019, 6:52 AM
YUKI
13 Answers
+ 11
noise = str(input()) noise_list = noise.split() animal = {"Grr":"Lion", "Ssss":"Snake", "Rawr":"Tiger", "Chirp":"Bird"} answer = " " for x in noise_list: answer += animal[x] + " " print(answer)
10th Jun 2020, 6:58 PM
John McCormack
John McCormack - avatar
+ 8
there is a variant of another solution: you Can use the method str. replace ("search", " desired"): noice = str(input()) n_1 = noice.replace ('Grr', 'Lion') n_2 = n_1.replace ('Ssss', 'Snake') n_3 = n_2.replace ('Chirp', 'Bird') n_4 = n_3.replace ('Rawr', 'Tiger') print (n_4)
9th Jun 2020, 3:44 PM
Jhon Doe
Jhon Doe - avatar
+ 3
noise_made = str(input()) if noise_made == "Chirp": print("Bird") if noise_made == "Rawr": print ("Tiger") if noise_made == "Grr": print ("Lion") if noise_made == "Ssss": print("Snake") What mistake I made
6th Jun 2021, 3:37 AM
K Anuj
K Anuj - avatar
+ 2
can someone say why the below code don’t work ?! s=input() print (s.replace('Grr','Lion').replace('Rawr','Tiger').replace('Ssss','Snake').replace('Chrip','Bird'))
28th Nov 2020, 2:44 AM
Kian
Kian - avatar
+ 2
omg , thank you man
29th Jan 2021, 7:56 PM
Kian
Kian - avatar
+ 2
n = {'G':'Lion', 'R':'Tiger', 'S':'Snake', 'C':'Bird'} for e in (nl:= input().split()): nl[nl.index(e)] = n[e[0]] print(' '.join(nl))
21st Sep 2022, 5:28 PM
Jacopo Cossu
Jacopo Cossu - avatar
+ 1
Thanks For This code And Fixed The Problem I Forgot How To Change List To String And Thanks For That Too noise = str(input()) noise_list = noise.split() animal = [] for x in noise_list: if x == 'Grr': animal.append('Lion') elif x == 'Rawr': animal.append('Tiger') elif x == 'Ssss': animal.append('Snake') elif x == 'Chirp': animal.append('Bird') else: continue animal_str = ' '.join(animal) print(animal_str)
21st Feb 2020, 8:34 AM
Sayed Ajmal Hashimi
Sayed Ajmal Hashimi - avatar
+ 1
hey Anuj 1st you should know python default input type is “string”, so you don’t need to make it string again 2nd your code can answer for one input, for example if my input be like “Ssss Grr” Your code answer wrong
8th Oct 2021, 11:28 AM
Kian
Kian - avatar
+ 1
sound = list(input()) for x in sound: if x == "G": print("Lion" , end = ' ') elif x == "R": print("Tiger" , end = ' ') elif x == "S": print("Snake" , end = ' ') elif x == "C": print("Bird" , end = ' ')
22nd Mar 2022, 11:01 AM
Max Im
+ 1
n = {'G':'Lion', 'R':'Tiger', 'S':'Snake', 'C':'Bird'} a ='' for e in input().split(): a += ' '+n[e[0]] print(a)
21st Sep 2022, 5:24 PM
Jacopo Cossu
Jacopo Cossu - avatar
0
Thank you for advice!
31st Dec 2019, 1:17 PM
YUKI
20th Oct 2020, 7:06 AM
イデリセ{非活性}
イデリセ{非活性} - avatar
0
Kian you made a typo, so your code isn't working. It should be 'Chirp' instead of 'Chrip'.
29th Jan 2021, 7:14 PM
asusar
asusar - avatar