Jungle Camping Python
Hello, I'm trying to figure out this task and I don't know why I have only 3/5 correct 🤔 maybe you can try to show me way where I did mistake, rather than to show me the answer 😇 thank you 🌹https://code.sololearn.com/cNi0OkxmIwT3/?ref=app
8/11/2022 6:04:29 PMSandra Heinzová
7 AnswersNew Answer
You are not using loop iteartion properly.. use the i value. Check for input : Grr Ssss Output should : Lion Snake But your code output wrong..
Hi, Sandra Heinzová ! 1) Instead of test if any of the animal sounds are in the list of input values, it’s better to test, one by one, if the input values are equal to any of the animals sounds. 2) Because there will never be two conditions that are true at the same time, it's better using 'if - elif - elif … instead of four if statements. Example: res =  for wd in my_input_list: if wd == "Coo": res.append(“Pigeons”) elif … …
Jayakrishna🇮🇳 thank you for directing me 💪after 3hrs I finally solved it.. Pheww 😅 My final code: For x in range(0, len(noise)) : if "Grr" in noise[ i ]: animal.append('Lion') i += 1 Elif... And so on Not quite elegant style I guess 😁 Coding is beautiful, so much ways to solve one problem💪
Per Bratthammar thank you for answer. I wasn't sure when use if and when elif.. Thanks for explanation.
I think, Simplest way is for i in noise : if i == "Grr" : animal.append("Lion ") .... You're welcome..
How to create a unity game in sololearn
How to create a calculator app using sololearn