0
python jungle animal question!!
im derping, someone tell me why this wont work plz! I thought i wws following the proper syntax for multiple replacements but obviously not! Thanks! noises = str(input()) animals = noises.replace("Grr", 'Lion').noises.replace('Rawr', 'Tiger').noises.replace('Ssss', 'Snake').noises.replace('Chirp', 'Bird') print(animals)
4 Antworten
+ 3
You're on the right track, no need to repeat noises every time as it is not a method. You just need noises.replace.replace...You get it
Edit. As side note x = str(input()) is redundant as input() reads automaticaly a string
+ 4
Yes only one str object is required which can be link to further replace() functions.
You can do that individually too like this
noises = input()
noises=noises.replace("Ssss","Snake")
noises=noises.replace("Rawr","Tiger")
noises=noises.replace ("Chirp","Bird")
noises=noises.replace ("Grr","Lion")
print(noises)
+ 1
thank you both!!!
+ 1
Brenner Pieszak You're welcome.