Failed in 2 case | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Failed in 2 case

i = str(input()) noise_list = i.split(" ") animal = [] for noise in noise_list: if 'Grr' in noise_list: animal.append('Lion') elif 'Rawr' in noise_list: animal.append('Tiger') elif 'Ssss' in noise_list: animal.append('Snake') elif 'Chirp' in noise_list: animal.append('Bird') else: continue animal_str = ' '.join(animal) print(animal_str)

19th Jan 2020, 7:41 AM
Sultan
2 Answers
+ 2
May be it is the order you are appending, what if you change the conditions in your for loop to sth like this if noise == "Grr" and change 'animal' from list to string ( i feel it is easier) animal = "" . . . if noise == "Grr" animal += " Lion"
19th Jan 2020, 7:59 AM
Besufkad Tsegaye
Besufkad Tsegaye - avatar
0
Try entering: Grr Chirp
19th Jan 2020, 8:00 AM
Seb TheS
Seb TheS - avatar