Write a Python program to get a string from the user, find the position of the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program to get a string from the user, find the position of the second a in the string (either 'a' or 'A' is OK), and print the position of it (e.g., the position of the first character is 0, the position of the second character is 1, and so on). If there are less than two a's, print -1 to indicate the second e is not found. In case the second e is found, print the substring after the second a. Input: a string. Output: The position of the second a in the string, the subsequent string following the second a. The prompt should be "Please enter a string: If the second a is found, the output should be formatted as "{:d) {:s}" Otherwise, the output should be NOTE: you should strictly follow the prompt/output format to get full marks. Functions like "find()" are strictly forbidden. You should use loops to deal with the characters one by one. Examplel (The contents highlighted by brown ink are inputs from the user): Please enter a string: This is for string -1 Example2 (The contents highlighted by brown ink are inputs from the user): Please enter a string: All about strings 4 bout strings Write a Python program to get a string from the user, find the position of the second a in the string (either 'a' or 'A' is OK), and print the position of it (e.g., the position of the first character is 0, the position of the second character is 1, and so on). If there are less than two a's, print -1 to indicate the second e is not found. In case the second e is found, print the substring after the second a. Input: a string. Output: The position of the second a in the string, the subsequent string following the second a. The prompt should be "Please enter a string: If the second a is found, the output should be formatted as "{:d) {:s}" Otherwise, the output should be NOTE: you should strictly follow the prompt/output format to get full marks. Functions like "find()" are strictly forbidden. You should use loops to deal with the characters one by one. Examplel (The contents highlighted by brown ink are inputs from the user): Please enter a string: This is for string -1 Example2 (The contents highlighted by brown ink are inputs from the user): Please enter a string: All about strings 4 bout strings
Expert Answer:
Answer rating: 100% (QA)
Here is my solution def findsecondastring Finds the position of the second a in the string Args stri... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
Morgan-Hunt Agency, a financial investment company, pays $300 to each of its salespersons as a year-end bonus, regardless of productivity. This is an example of a(n) Discuss in details.
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Your first assignment was to enter forecasting data. How will SAP use this information?
-
A Table is in first normal form if there are no repeating groups of data in any column. (True/False)
-
An experiment consists of selecting a number at random from the set of numbers {1, 2, 3, 4, 5, 6, 7, 8, 9}. Find the probability that the number selected is (a) Less than 4. (b) Odd. (c) Less than 4...
-
Marilyn Helm Retailers is attempting to decide on a location for a new retail outlet. At the moment, the firm has three alternativesstay where it is but enlarge the facility; locate along the main...
-
Throughout an engagement, the independent auditor makes observations, documents evidence, confirms transactions, tests accounting data, compares recorded amounts, and makes many inquiries, all vkfith...
-
A Barberton Glass Co. truck was transporting large sheets of glass down the highway. Elliot Schultz was driving his automobile some distance behind the truck. Because of the negligent way that the...
-
1. Two ice cubes of 15 g each are taken form a freezer at -12 Celsius and placed in a cup containing 250 g of water at room temperature say 22 Celsius. Calculate the final temperature of the mixture?...
-
CableTech Bell Corporation (CTB) operates in the telecommunications industry. CTB has two divisions: the Phone Division and the Cable Service Division. The Phone Division manufactures telephones in...
-
Solve the system by using elementary row operations on the equations. Follow the systematic elimination procedure. X + 5x2 = 13 2x + 7x2 = 14 Find the solution to the system of equations. 0
-
Think about a culture of interest to you. Do the following: A. Describe five preconceptions or stereotypes you have about the culture. B. Conduct some research and find out how correct you are. Use...
-
Interview at least two professionals from at least two generations. Ask them about their views of similarities and differences between professionals of various generations. Consider asking questions...
-
Read at least three blogs or articles about trust and/or ethics from a reputable organization or other source. Choose an issue that interests you, and in four to five paragraphs, summarize key...
-
Interview an international student at your university. Report about the interview in five of the following ten areas: Business in the students country. Popular entertainment in the country. ...
-
Think about a specific professional context, and respond to each of the following questions. For the context, you can use a current or previous job. Or you could use a professional or student...
-
Machine C was purchased on 30 November 2021 from an American supplier. Orico Limited paid the purchase price of $100 000 on 31 January 2022. The following exchange rates are applicable: Date Spot...
-
If a and b are positive numbers, find the maximum value of f ( x ) = x a (9 x ) b on the interval 0 x 9.
-
The five-year-old TowerWood hotel chain needs help designing its Web site. The company maintains properties in all the large U.S. tourist communities such as Orlando, Florida (near Disney World);...
-
Create an entity-relationship diagram for a genealogy software package called PeopleTree to keep track of ancestors. Assume that each person will be on a Person table and that one person may have one...
-
What are the disadvantages of using a client/server approach?
-
If the majority in a community finds an artistic representation of their religion, race, or culture offensive, should it be censored? The statue of President Theodore Roosevelt flanked by an African...
-
What are some of the ways in which the arts of various cultures differ from each other?
-
Compare the ways that art expresses cultural themes using the examples of manga, anime, and cockfighting.
Study smarter with the SolutionInn App