id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

dvermes@scarsdaleschools.org > replace
prev  |  next  |  chance

Write a function that returns a copy of string s with all occurrences of substring old replaced by new.


replace('The dog was walking and saw a fox and ran', 'an', 'bark') → 'The dog was walking barkd saw a fox barkd rbark'
replace('The dog was walking and saw a fox and ran', 'and', 'x') → 'The dog was walking x saw a fox x ran'
replace('eneenie', 'en', 'no') → 'noenoie'

...Save, Compile, Run (ctrl-enter)

def replace(s, old, new):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 100

Copyright Nick Parlante 2017 - privacy