+ 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
13 Antworten
+ 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)
+ 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)
+ 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
+ 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'))
+ 2
omg , thank you man
+ 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))
+ 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)
+ 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
+ 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 = ' ')
+ 1
n = {'G':'Lion', 'R':'Tiger', 'S':'Snake', 'C':'Bird'}
a =''
for e in input().split():
a += ' '+n[e[0]]
print(a)
0
Thank you for advice!
0
Kian you made a typo, so your code isn't working. It should be 'Chirp' instead of 'Chrip'.