oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Replace #344

Open oldoc63 opened 1 year ago

oldoc63 commented 1 year ago

The next string method we will cover is .replace(). Replace takes two arguments and replaces all instances of the first argument in a string with the second argument.

oldoc63 commented 1 year ago

Here we used .replace() to change every instance of a space in the string above to be an underscore instead. Note that in this example, we used a single character, but these substrings can be multiple characters long!

oldoc63 commented 1 year ago

The poetry organization has sent over the bio for Jean Toomer as it currently exists on their site. Notice that there was a mistake with his last name and all instances of Toomer are lacking one o.

Use .replace() to change all instances of Tomer in the bio to Toomer. Save the updated bio to the string toomer_bio_fixed.