+ 3
Problem in project
Can’t see what’s wrong it goes but does not give rite out put Sound =input() if Sound=='Grr': print ('Lion') elif Sound=='Rawr': print ('Tiger') elif Sound=='Ssss': print ('Snake') elif Sound=='Chirp': print ('Bird ') New. Don’t understand y I need to put sound=input And what do I do that if someone puts in lion lion twice it should print 2 times
14 Réponses
+ 3
Lz1234
I hope this may help you
https://code.sololearn.com/coHdk3ewFaaZ/
+ 2
https://code.sololearn.com/c2oBSk4n53uV/
+ 1
SoloProg
Jay Matthews
Im not useing any of the reseved words
+ 1
Mahad Ahmed
Your sound in the forest dose not work Put in
Lion
Lion
And it said no out put
+ 1
Jay Matthews
Can you explain in simple termanoligy y i need to do this sound =input get that thats the way but i want to understand y
+ 1
Thanx
+ 1
You fix it nice
+ 1
Lz1234 Does this work? :-
inp = input().lower().split()
sounds = {
"lion" : "grr",
"tiger" : "rawr",
"snake" : "ssss",
"bird" : "chirp"
}
a, b = tuple(zip(*sounds.items()))
for x in inp: print(a[b.index(x)] if x in b else x, end=" ")
+ 1
Hello. If you want the name of the animal that makes this sound to be displayed N times when you enter the name of the sounds N times, use my code:
https://code.sololearn.com/cwUe3xJ7ynA0/?ref=app
0
Lz1234 I suggest you to use a dictionary here.
0
Jay Matthews
K get that if you dont mined can you tell me what to do that if some one puts in more than one sound it shold give both rasolts ex(Grr Chirp the out put shuld be Lion Bird )ass of now it only goes once
0
Most of the answer has been explained very nicely by Jay Matthews , just to clear the basics (afaik, I can be wrong, but I learnt at FreeCodeCamp): when you write the statement "input()" you basically are giving instruction(s) for the processor chip to handle, 'do this and that'. However think about it, did you asked the processor to 'maintain the input obtained in the memory(RAM) retrievable by me'? If you stress on it, you will find that this won't make sense unless you could have a sort book keeping label for that memory piece, that book keeping label is a variable assignment :)
0
You can change sound into any no problem bro
- 1
dawtw