+ 7

What's wrong with it?

Can't catch mistake (jungle camping code coach) https://code.sololearn.com/cuIE6fk0MHHZ/?ref=app

18th Mar 2020, 8:44 PM
Dananan Bananan
Dananan Bananan - avatar
28 Antworten
+ 5
Look it works. Just replace i with x in the if else and don't convert your input to string explicitly... x=input().split(" ") animals=[] for i in x: print(i) if "Grr" in i: animals.append("Lion") elif "Rawr" in i: animals.append("Tiger") elif "Ssss" in i: animals.append("Snake") elif "Chrip" in i: animals.append("Bird") animals_j=" ".join(animals) print(animals_j)
19th Mar 2020, 11:06 AM
Syed Waseem
Syed Waseem - avatar
+ 8
Dananan Bananan andriy kan Tiger not Tigger Chirp not Chrip Now the code should work.
18th Mar 2020, 10:01 PM
Denise Roßberg
Denise Roßberg - avatar
+ 6
Tiger not Tigger ;)
18th Mar 2020, 9:54 PM
Denise Roßberg
Denise Roßberg - avatar
+ 5
I don't know what you expected from your code. I just made it correct. I commented out input() function and set some value to x It outputs the result: [EDITED]: I uncommented the second line with input() function. So you can try it https://code.sololearn.com/cy4Cj8ZV9vSP
18th Mar 2020, 9:19 PM
andriy kan
andriy kan - avatar
20th Mar 2020, 4:17 AM
David Ashton
David Ashton - avatar
+ 4
x=input().split(" ") animals=[] for i in x: if "Grr" == i: animals.append("Lion") elif "Rawr" == i: animals.append("Tiger") elif "Ssss" == i: animals.append("Snake") elif "Chirp" == i: animals.append("Bird") else: continue animals_j=" ".join(animals) print(animals_j)
18th Mar 2020, 8:59 PM
andriy kan
andriy kan - avatar
+ 3
s=input("") n=s.split(' ') for i in n: if i=='Grr': print("Lion",end=" ") elif i=='Rawr': print("Tiger",end=" ") elif i=="Ssss": print("Snake",end=" ") elif i=="Chirp": print("Bird",end=" ") you can try this also...no need to create another list
19th Mar 2020, 4:23 PM
ANJALI SAHU
+ 2
Sorry, I can't understand you. Did you try the code in code playground that I've posted? https://code.sololearn.com/cy4Cj8ZV9vSP I replace input with the string: "Rawr Chirp Ssss" Output is: Tiger Bird Snake If you want to use user input just uncomment the line #2
18th Mar 2020, 9:43 PM
andriy kan
andriy kan - avatar
+ 2
s=input().split() for y in s: if(y=="Grr"): print("Lion",end=' ') elif(y=="Rawr"): print("Tiger",end=' ') elif(y=="Ssss"): print("Snake",end=' ') else: print("Bird",end=' ') I done it like this
20th Mar 2020, 11:13 AM
Aphran Mohammed
Aphran Mohammed - avatar
+ 2
Petro Skulsky, please do not spam.
20th Mar 2020, 1:37 PM
HonFu
HonFu - avatar
+ 2
because default represents else in switch case ( if you know if .. else ) when no condition is true it goes to else the same with switch here at the example you have 3 different cases and you switch x value if x == 1 (first case) it will print x value only without any addition if x == 2 (second case) it will print x value and add 2 to it so the result would be 3 + 2 = 5 will print 5 if x value not equal to 1 or 2 it will go to the default and add 5 to x value so the result would be 8 i hope you understand gerard
21st Mar 2020, 11:23 PM
Mayar Yasser Elabbasy
Mayar Yasser Elabbasy - avatar
+ 1
С этого и нужно было начинать) как указал(а) Denise Roßberg у тебя ошибка в слове Tiger. as Denise Roßberg pointed out, you have a mistake in the word Tiger.
18th Mar 2020, 9:59 PM
andriy kan
andriy kan - avatar
+ 1
Try this a=input() lst=[] sa=a.split() for i in sa: if i=='Grr': lst.append('Lion') elif i=='Rawr': lst.append('Tiger') elif i=='Ssss': lst.append('Snake') elif i=='Chirp': lst.append('Bird') result=' '.join(lst) print(result)
19th Mar 2020, 6:16 AM
Abdollahi Mohammed
Abdollahi Mohammed - avatar
+ 1
You need to print "Chirp" instead of "Chrip" and "Tiger" instead of "Tigger"
20th Mar 2020, 4:20 PM
F L a Z z Y
F L a Z z Y - avatar
0
I tried this as well but it results in no output
18th Mar 2020, 9:11 PM
Dananan Bananan
Dananan Bananan - avatar
0
https://www.sololearn.com/coach/45?ref=app It's from this code coach and for me it still doesn't work
18th Mar 2020, 9:32 PM
Dananan Bananan
Dananan Bananan - avatar
0
I've solved it with end parameter but couldn't solve it with append function
18th Mar 2020, 9:34 PM
Dananan Bananan
Dananan Bananan - avatar
0
Я вводил этот код в jungle camping code coach, 3ий и 5ый тест не исполняются, не получается найти ошибку
18th Mar 2020, 9:55 PM
Dananan Bananan
Dananan Bananan - avatar
0
After I've corrected tiGer mistake the 3rd test in jungle camping does not execute
18th Mar 2020, 9:58 PM
Dananan Bananan
Dananan Bananan - avatar
0
Thank you all! Now it works!
18th Mar 2020, 10:04 PM
Dananan Bananan
Dananan Bananan - avatar