Page 185 -
P. 185

comprehending data


                          Code Magnets


                          Let’s create a function called sanitize(),  which takes as input
                          a string from each of the athlete’s lists. The function then processes
                          the string to replace any dashes or colons found with a period and
                          returns the sanitized string. Note: if the string already contains a
                          period, there’s no need to sanitize it.

                          Rearrange the code magnets at the bottom of the page to provide
                          the required functionality.





                          def sanitize(time_string):
























                                 return(mins + '.' + secs)


                                        Return the sanitized time string to
                                        the caller of this function.


            Your magnets are                                            elif ':' in time_string:
            waiting.              time_string.split(splitter)


                                                                                 return(time_string)
                            else:         if '-' in time_string:             (mins, secs) =
                                                          splitter = '-'
                                     splitter = ':'


                                                                                      you are here 4    149
   180   181   182   183   184   185   186   187   188   189   190