Home / Expert Answers / Computer Science / given-a-string-s-with-length-n-that-contains-numbers-lowercase-characters-and-39-39-you-are-requir-pa723

(Solved): Given a string S with length N that contains numbers, lowercase characters, and '-', you are requir ...



student submitted image, transcription available below
Given a string with length that contains numbers, lowercase characters, and '-', you are required to sum all the substrings that can be converted to a number. For example, if we let "12a-a-53-1", then all substrings that can be converted to a number will be "1", "12", "2", "-5", "-53", "5", "53", "3", "-1", "1". The summation of all valid substrings is . You should complete the function as follows. Note: don't change the function format and only add code inside the function block. Case 1: . In this case, the function should return 18. Case 2: "1a12-11-". In this case, the function should return 17. def , sum_str S: a string return a number ans pass sum_str ("12a-a-53-1") def sum_str(S): S: a string return a number ans pass sum_str ("12a-a-53-1")


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe