Computers and Technology

First, we will explore some of methods from the str class. a) join during the last assignment you made a function that echoed a string several times with a seperator between each repetition. here we will achieve a similar goal through the use of the join) method of the str class. when join) is called on a str object (let's call it separator) with a list as its argument, it joins the elements of the list, seperating each one by separator below we define a a list my_list. use the join) method on the string you define as separatoro join the elements in my_list seperated by the-character. save the output to a new variable called joined string .the output should look as follows: python-is-so-much-fun in [ ]: # this variable provided for you my_list'python','s',so'much'fun' # your code here raise notimplementederror) in assert isinstance(joined string, str) assert joined _string 'python-is-so-much-fun b) replace now try to use the replace method to update the string statement such that it replaces ucla to ucsd if you are unsure how use replace you can run str. replace? to look at documentation. note that using replace returns a new string that you need to assign to a variable if you want to keep a reference to it ( replace is not 'inplace) for this question, overwrite statement as the assignment to the output of the replace call in [ ]: # this code provided for you statement'ucla is the best uc in southern california. # your code here raise notimplementederror) in assert isinstance (statement, str) assert statement'ucsd is the best uc in southern california. c) replace for dropping characters use the replace method to remove all the exclamation points in the string excessive. assign the output of doing this to a variable called fixed hint: you can drop characters with replace by 'replacing them with an empty string in [ ]: # this variable provided for you excessive exclamation is the best! i # your code here raise notimplementederror in assert isinstance (fixed, str) assert fixed-= 'using excessive exclamation points is the best . d) clearing all punctuation with replace now we want to generalize what we did in 'c)' to remove all punctuation using the replace() method. write a for loop to loop over every character in string. punctuation. inside the loop, call replace on too_much with the current punctuation character to remove it, like we did in 'c)' to do this, inside the loop, re-assign too_much to be the ouput of calling replace on too_much, so that you are replacing too_much with it's updated version every time. in [ ]: # this variable provided for you too-much '1, think th@at11 punctuation may ? > > be the bes$$$t thing thats: ever! been l invented 111 111. = : # your code here raise notimplementederror) in assert isinstance (too much, st) assert too_muchi think that punctuation may be the best thing thats ever been invented

answer
Answers: 2

Similar questions

Do you know the correct answer?
First, we will explore some of methods from the str class. a) join during the last assignment you ma...

Questions in other subjects:

Konu
Medicine, 03.09.2020 07:01
Konu
Computers and Technology, 03.09.2020 07:01