Jungle Camping, Loop not terminating after running | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Jungle Camping, Loop not terminating after running

Please tell the issue with my code https://code.sololearn.com/cW5I8ohd5JN4/?ref=app

7th Sep 2021, 8:24 AM
Shaurya Agarwal
Shaurya Agarwal - avatar
6 Respostas
+ 3
You donā€™t need variables for each sound, you also need to split the string on spaces ā€œ ā€œ. See working example below: what_animal = input().split(" ") animals = "" for noise in what_animal: if noise == "Grr": animals += "Lion " if noise == "Rawr": animals += "Tiger " if noise == "Ssss": animals += "Snake " if noise == "Chirp": animals += "Bird " print(animals)
7th Sep 2021, 8:31 AM
DavX
DavX - avatar
+ 3
input().split()
7th Sep 2021, 8:28 AM
Abhay
Abhay - avatar
0
DavX Thank you for your help
7th Sep 2021, 9:50 AM
Shaurya Agarwal
Shaurya Agarwal - avatar
0
You are most welcome šŸ‘šŸ‘ŠāœŒļø
7th Sep 2021, 9:52 AM
DavX
DavX - avatar
0
Why do we need to use input().split(" ")
8th Sep 2021, 7:59 AM
Shaurya Agarwal
Shaurya Agarwal - avatar
0
Input Format: A string that represent the noises that you hear with a space between them. input().split(ā€œ ā€œ) Splits the input string on ā€œ ā€œ or spaces, since the input is provided as one long string with spaces. Which returns a list, each noise heard being a separate item. You can then iterate over the list...
8th Sep 2021, 8:16 AM
DavX
DavX - avatar