+ 1

Why doesn't it work? Jungle camping problem

animal = list((input().split()) for n in animal: if n == 'Grr': print ("Lion ") elif n == 'Rawr' print ("Tiger ") elif n == 'Ssss' print ("Snake ") elif n == 'Chirp' print ("Bird ")

25th Jul 2020, 10:09 AM
Silltrane
Silltrane - avatar
3 Respostas
+ 3
You didn't close the opening list parenthesis in first line And there are missing semicolons after elif statements Also the output would come as for Grr Grr: Lion Lion instead of Lion Lion but that is allowed as well
25th Jul 2020, 10:17 AM
Abhay
Abhay - avatar
+ 8
Regardless of all that was mentioned, the firts line of the code can be shortened: animal = list((input().split())) animal = input().split() - There is no need to have brackets around input() - There is no need to convert the input result to list, this is done from pythom by using split()
25th Jul 2020, 10:34 AM
Lothar
Lothar - avatar
+ 1
This will work for You. You have some mistakes in your code animal = input().split() for n in animal: if n == 'Grr': print ("Lion ") elif n == 'Rawr': print ("Tiger ") elif n == 'Ssss': print ("Snake ") elif n == 'Chirp': print ("Bird ")
26th Jul 2020, 4:51 AM
Kartikey Kumar
Kartikey Kumar - avatar