Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I can't figure this one out (python): def transform_string(source: str, s1: str, s2: str) -> str: Returns a modified string of the same length
I can't figure this one out (python):
def transform_string(source: str, s1: str, s2: str) -> str: """ Returns a modified string of the same length as the source. """ answer here
TEST CASE:
Description : Testing with randomly generated encoded strings Input : ('GGGGGGBEQTUEBOXYIZELYSWULPSDMDPYVVVVVECFIIAZZPCIUESSPMMYCYETAYYMLBJDSYRRJLXSQBURYWFWOPECZDCUFBCMAUI', 'KH5GVN4', '5HCDSL9') ('MWQOCFMLZL}.IUR$#%#~YBY*{WIVHSVEHSJUHEH**-}[W$,/~*RZ5JCDD3SN@#!,0PY5UIOA9K2LEDVIMCN1PTS5LUIG8W1(%_9OD4LUACPVCURWV5', 'FHBZJ37', 'SJR80CD') ('6PLVAJ6Y3DAMY5DCV5LGY7YYHO7JYTCIGKENVILAA1PWU4NCX1UM2MUKC4V1WPHO7UJW4FVO3OYCT2K4YCH7CH0NTXHZJ7SZZJ2', '6RIB', 'DES9') ('IIIIIIXV2WYHR3NYG5UQV9UBMH9YUTSV11111JWGH5BMU6SPWA5GR.@)^SRYExpected : DDDDDD SSSSS D D == ===== == S S ===== ===== ! ! ==== ===== ! ! ===== ====== ==== D D ! ! ! ! ! S ! ! ! ! ! ! ! ! ! ! ! ! ! ! D D ! ! ! ! ! SSSSS ! ! ! ! ! ! ! ! ! ! ! !==== ==== D D !====! ! !====! S ! !===! ! ! ! ! ! ! !===! ! ! D D ! ! ! ! ! S S ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! DDDDDD ! ! ! ! ! SSSSS ! ! ! ==== ==== ! ==== ! ! ====== ====
Write a function that receives three strings (source, sl and s2) and then returns a modified string of the same length as the source. Source string should be processed one character at the time and output string should be constructed according to the following rules: I 1) If the character from the source string is present in sl, it should be replaced by the character at the same index in s2 2) Otherwise, if the character is: a) Uppercase letter -> replace by ' b) Lowercase letter -> replace by '#' c) Digit -> replace by '!' d) Anything else -> replace by '=' You may assume that strings si and s2 have the same length
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started