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
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.
+ 4
I just did it mannn!
Thanks a bunch, Aj. Bless 😁
https://code.sololearn.com/cKOb9Rk7Nc6h/?ref=app
+ 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'
+ 2
Input of the sounds would have spaces in between, and the output has to be configured based on inputted sounds 🥲🥲
+ 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
+ 2
(end = " ")
This would certainly stick for a very long time 😂😂🥲
+ 2
Yes, I did the correction and completed the task.
Thank you so much
+ 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
+ 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)
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)
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.🥰
0
Topical Media
Complete html course everything is there