Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Assume you decide to use more of your new Python skills, so you are going to write a function that looks for a string

5. Assume you decide to use more of your new Python skills, so you are going to write a function that looks for a string present in another string and enclosed in tags, extract it, and return the index position of the string. Also print out the resulting string. (Hint: Use either str.find( ) or str.index( ) method which accepts arguments and produces output as shown below. >>> xtrfrmtag("violet", "Wow a cake with a currant") Cake To encode a message, you look up letters in the original alphabet. Whatever index the letter is, you take the corresponding letter from the keyword cipher alphabetwhich you can easily generate if you know the keyword. Following there is the function encode. def encode(string,keyletters): alpha="abcdefghijklmnopqrstuvwxyz" secret = "" for letter in string: index = alpha.find(letter) secret = secret+keyletters[index] print secret _ >>> encode("this is a test","earthbcdfgijklmnopqsuvwxyz") sdfqzfqzezshqs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

Give the phase and the specific volume.

Answered: 1 week ago

Question

Define a database and a database management system.

Answered: 1 week ago

Question

a. How will the leader be selected?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago