+ 1
Jungle Camping, Loop not terminating after running
Please tell the issue with my code https://code.sololearn.com/cW5I8ohd5JN4/?ref=app
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)
+ 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...