Question: Python 3 1a) Define a function called escape_URL_char() which takes a single-character* string and checks if it needs to be escaped or not. If it
Python 3
1a) Define a function called escape_URL_char() which takes a single-character* string and checks if it needs to be escaped or not. If it does not need to be escaped, the function should just return the given string. If it does need to be escaped, the function should return an excape sequence that represents that character.
For the purposes of this problem*, the only characters that need to be escaped are the space " " (which should be replaced by a plus sign "+"), the forward slash "/" (which should be replaced by "%2F"), the hash sign "#" (which should be replaced by "%23"), and the equals sign "=" (which should be replaced by "%3D").
So for example, escape_URL_char(" ") should return "+", escape_URL_char("=")should return "%3D", and escape_URL_char("X") should return "X".
1b) Define a function called escape_URL() which takes a string (typically with more than one character, but not necessarily) and returns an escaped version of that string, usingescape_URL_char() to escape all the necessary characters. So for example,escape_URL("12/3 = 4") should return "12%2F3+%3D+4" and escape_URL("foobar")should return "foobar".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
