Question: Python Question 4.30 LAB: Magic String The code template below takes as input two things the first, wy_string is a string literal of unknown length,

Python Question
Python Question 4.30 LAB: Magic String The code template below takes as

4.30 LAB: Magic String The code template below takes as input two things the first, wy_string is a string literal of unknown length, and the second magicia three character string Complete the program to assign the variable my_result with one of four possible values . 3 if magic is a substring of my_string 2 if any two character substring of magic is also a substring of my_string but magic toelf is not 1. If any of the characters in magic appears in my_string, but no two character substrings nor magic are tubetrings of my_string 0, if no characters in magic appear at all in my_string For example, suppose wy_string lu 'The main architect was Slartibartfast. Then if magic is tart' my_result is since art is a substring of my_string if magic is 'arx', my_result is because 'ar is a two character substring of my_string if magic is jam my_result is because mis a one character substring of wy_string If magic is xjzmy_result iso, of course You may assume magte always has only three unique characters (that need not be letters). You should assume cose cenitivity that is, for example, a and are not the same letter . Some hints 1. The expression magic in my_string return true if the string literal labeled with the name magte is substring of the string literal labeled with the name ny_strine 2 magic[] return the oth (that is the first character in wale nagte (1) returns the Tot (that is the second character in magic and so on 3 magic[0:2) returns a string built from the oth and 1st characters of magic magie[13] contains the lot and 2nd only LAN ACTIVITY 4:30. LAB Magic String 0/0 main py Load template 1 wy_string Input) 2 magic Input) your code goes here 5 print result) 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!