Python Task... Jungle Camping | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python Task... Jungle Camping

You are camping alone out in the jungle and you hear some animals in the dark nearby. Based on the noise they make, determine which animals they are. Task: You are given the noises made by different animals that you can hear in the dark, evaluate each noise to determine which animal it belongs to. Lions say 'Grr', Tigers say 'Rawr', Snakes say 'Ssss', and Birds say 'Chirp'. Input Format: A string that represent the noises that you hear with a space between them. Output Format: A string that includes each animal that you hear with a space after each one. (animals can repeat) Sample Input: Rawr Chirp Ssss Sample Output: Tiger Bird Snake My code so far https://code.sololearn.com/cKOb9Rk7Nc6h/?ref=app

31st Aug 2022, 10:14 AM
Victor
12 Answers
+ 4
Victor Split input with space so you will get a list. Now iterate list and compare each value with given value to print respected animal.
31st Aug 2022, 10:20 AM
A͢J
A͢J - avatar
+ 4
I just did it mannn! Thanks a bunch, Aj. Bless 😁 https://code.sololearn.com/cKOb9Rk7Nc6h/?ref=app
31st Aug 2022, 3:35 PM
Victor
+ 3
Victor Why did you assign animal names to variable 'all' and why there is continue? Do you know why use continue? And you are printing input 'x' does it makes any sense. You have to print animal names when condition meet. And you have assigned same animal name 'Tigers'
31st Aug 2022, 3:01 PM
A͢J
A͢J - avatar
+ 2
Input of the sounds would have spaces in between, and the output has to be configured based on inputted sounds 🥲🥲
31st Aug 2022, 10:16 AM
Victor
+ 2
Victor Add end = ' ' in each print statement like this' print('Tigers', end = ' ') This will avoid to print with new line. Check each spelling again. Lion says 'Grr' not 'Tiger' Read task description again
31st Aug 2022, 3:26 PM
A͢J
A͢J - avatar
+ 2
(end = " ") This would certainly stick for a very long time 😂😂🥲
31st Aug 2022, 3:36 PM
Victor
+ 2
Yes, I did the correction and completed the task. Thank you so much
31st Aug 2022, 4:46 PM
Victor
+ 1
Hello, Aj https://code.sololearn.com/cKOb9Rk7Nc6h/?ref=app I've tried many thing, including the replace function. Still failed. Kindly walk me through this please. Thanks
31st Aug 2022, 2:52 PM
Victor
+ 1
https://code.sololearn.com/cKOb9Rk7Nc6h/?ref=app Sent a wrong link, sorry The output according to the task is supposed to print out in one line, in the order of the sounds entered (separated by spaces)
31st Aug 2022, 3:18 PM
Victor
0
x = input() y = x.split() #splits the string into a list so we can iterate on each word z = "" #This is going to be the string we add to with each iteration for ele in y: if ele == "Grr": z += "Lion " elif ele == "Rawr": z += "Tiger " elif ele == "Ssss": z += "Snake " elif ele == "Chirp": z += "Bird " #each iteration of the above loop will identify the sound, add the corresponding animal and a space(the space is important for the string structure) to the z variable. Adding to the z variable string with each iteration. print(z)
1st Sep 2022, 9:39 PM
Denis Mcgrath
Denis Mcgrath - avatar
0
I'm a begenner, I'm not geting any link of css file here. Please help me telling how can I use css and js with html.🥰
2nd Sep 2022, 1:51 AM
Topical Media
Topical Media - avatar
0
Topical Media Complete html course everything is there
2nd Sep 2022, 4:29 AM
A͢J
A͢J - avatar