Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def occurs_within(word1: str, word2: str) -> bool: ''' Given two strings, word1 and word2, return True iff ALL characters in word2 occur in word1, in

def occurs_within(word1: str, word2: str) -> bool: ''' Given two strings, word1 and word2, return True iff ALL characters in word2 occur in word1, in their original order (e.g. if word2 was "hey", then we would return True iff within word1, the letter "h" occurred at an index earlier than "e", and "e" occurred in word1 at an index earlier than "y".) Assume all letters in the given words are lowercase. You may use string methods if any are useful.

>>> occurs_within('aaacaabxyt', 'cat') True >>> occurs_within('tac', 'cat') False

>>> occurs_within('oboe', 'bob') False >>> occurs_within('ecxbtalt', 'exalt') True >>> occurs_within('ecxbtal', 'exalt') False '''

Python solution and as simple as possible please

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

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions