Question

Need answer in Python 3.8, with indentation and comments shown, please.

16.4* (Pattern matching) Write a program that prompts the user to enter two strings and tests whether the second string is a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Here is the python code as per yuor requirement

Raw code:

#getting two string and making them as lower case

s1=input("Enter a string s1: ").lower()

s2=input("Enter a string s2: ").lower()

#checking if the string 2 is exist in the string 1

if s2 in s1:

#if yes print the index value of string 2 in string1

print("matched at index",s1.index(s2))

#else print that there is no substring

else:

print("not matched")

Code in the editor:

1 2 3 4 5 #getting two string and making them as lower case sl=input(Enter a string s1: ). lower() s2=input(Enter a string

output:

ed folder/statistics.py Enter a string s1: Mississippi Enter a string s2: sip matched at index 6 Ajay-Kumars-MacBook-Air: un

Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.

"Please refer to the screenshot of the code to understand the indentation of the code".

Thank you! Do upvote.

Add a comment
Know the answer?
Add Answer to:
Need answer in Python 3.8, with indentation and comments shown, please. 16.4* (Pattern matching) Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Task Algorithms: Pattern Matching (in java) Write a program that gets two strings from user, size...

    Task Algorithms: Pattern Matching (in java) Write a program that gets two strings from user, size and pattern, and checks if pattern exists inside size, if it exists then program returns index of first character of pattern inside size, otherwise it returns -1. The method should not use built-in methods such as indexOf , find, etc. Only charAt and length are allowed to use. Analyze the time complexity of your algorithm. Your solution is not allowed to be> = O...

  • Coding for Python - The pattern detection problem – part 3: def pattern_search_max(data_series, pattern, threshold) Plea...

    Coding for Python - The pattern detection problem – part 3: def pattern_search_max(data_series, pattern, threshold) Please do not use 'print' or 'input' statements. Context of the assignment is: In this assignment, your goal is to write a Python program to determine whether a given pattern appears in a data series, and if so, where it is located in the data series. Please see attachments below: We need to consider the following cases: Case 1 - It is possible that the...

  • Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a scr...

    Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a screen shot for code. Write clear code with comments and follow coding convention. Comments should include your name, student number and subject code on top of your code Question 1 Create a list to store all the subject codes that you are currently doing at UOW Then use for loop to display it in a table as in the...

  • Please solve in python and provide comments explaining your codes. Your output must be the same...

    Please solve in python and provide comments explaining your codes. Your output must be the same as the example and result given below in the images. This task is to write a very basic text editor. It allows you to add, delete and modify lines of text.  Use a list of strings to store the lines, with each list element being one line. The elements of the list are modified according the commands given by the user. The editor repeatedly: 1.    displays...

  • 23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4...

    23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT