+ 1
Jungle Camping, Loop not terminating after running
Please tell the issue with my code https://code.sololearn.com/cW5I8ohd5JN4/?ref=app
6 RĂ©ponses
+ 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)
+ 3
input().split()
0
DavX Thank you for your help
0
You are most welcome đđâïž
0
Why do we need to use input().split(" ")
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...