Question: First, we will explore some of methods from the str class. a) join During the last assignment you made a function that echoed a
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 separator 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, separating each one by separator . Below we define a a list my_list. Use the join() method on the string you define as separator by the '*' character. Save the output to a new variable called joined_string. The output should look as follows: 'Python*is*so*much* fun' 1 #your code here 2 raise NotImplementedError 1 assert type (joined_string) == str 2 assert joined_string == 'Python*is*so*much* fun' = '* to join the elements in my_list separated
Step by Step Solution
3.28 Rating (148 Votes )
There are 3 Steps involved in it
The image displays a Python exercise that instructs on how to use the join method f... View full answer
Get step-by-step solutions from verified subject matter experts
