python jungle animal question!! | Sololearn: Learn to code for FREE!


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)

2/28/2020 7:41:12 PM

Brenner Pieszak

4 Answers

New Answer


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


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)


thank you both!!!


Brenner Pieszak You're welcome.