(Harry Potter Transformation) You are to solve the problem of checking for Harry Potter Transformation for two strings. Twe trings are said to satisfy Harry Potter Transformation if the letters of one...

(Harry Potter Transformation) You are to solve the problem of checking for Harry Potter Transformation for two strings. Twe trings are said to satisfy Harry Potter Transformation if the letters of one string could be rearranged to become the second string, with no more or no fewer characters (except for space). Exuples include: String-1 - tom marvolo niddle String-2 - i am lord Voldemort String-1 - harry potter String-2 - try hero part String-1 - severus Snape String-2 - save pureness String-1 - a computer String-2 - our pet mac Write a Python function harry0 to determine whether two strings satisfy Harry Potter Transformation. Function harry (s, t) Input: s and t are two strings, consisting only of lower case letters and space. Output: True 18 s and t satisfy Harry Potter Transformation and False otherwise. In Python, you could process cach letter in a string by considering it as a sequence, similar to the Head/Tail counting sample Python program. In other words, the following loop allows you to iterate through each letter in the string and print them out, skipping the space. stringi - "harry potter" for letter in string1: if letter ! - "": print(letter, end-"," In your .py file, you must include the following code for testing harry ("tom marvolo ziddle", i am lord voldemort") harry("harry potter", "my hero part") harry("a computer", "our pet mac") The outputs should be: Checking "tom marvolo riddle" with i am lord voldemort: True Checking "harry potter" with "my hero part": False Checking a computer" with "our pet mac": True When two strings do not satisfy the transformation, there must be some letters occurring with different frequency in both strings. Add a few lines to the function harry so that it can also print out the list of letters with too many or too few occurrences in the first string. Consider using ardt and chr() to simplify your program. The outputs should now be: Checking tom marvolo riddle" with "iam lord voldemort: True Checking "harry potter" with "my hero part": false Too many : Checking "a computer" with "our pet mae": True
Nov 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here