) Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message and prompt again for a valid data point. If entry has no comma Output: Error: No comma in string. (1 pt) If entry has more than one comma Output: Error: Too many commas in input. (1 pt) If entry after the comma is not an integer Output: Error: Comma not followed by an integer. (2 pts)

Answers

Answer 1

Answer:

In Python:

entry = input("Sentence: ")

while True:

   if entry.count(",") == 0:

       print("Error: No comma in string")

       entry = input("Sentence: ")

   elif entry.count(",") > 1:

       print("Error: Too many comma in input")

       entry = input("Sentence: ")

   else:

       ind = entry.index(',')+1

       if entry[ind].isnumeric() == False:

           print("Comma not followed by an integer")

           entry = input("Sentence: ")

       else:

           break

print("Valid Input")

Explanation:

This prompts the user for a sentence

entry = input("Sentence: ")

The following loop is repeated until the user enters a valid entry

while True:

This is executed if the number of commas is 0

   if entry.count(",") == 0:

       print("Error: No comma in string")

       entry = input("Sentence: ")

This is executed if the number of commas is more than 1

   elif entry.count(",") > 1:

       print("Error: Too many comma in input")

       entry = input("Sentence: ")

This is executed if the number of commas is 1

   else:

This calculates the next index after the comma

       ind = entry.index(',')+1

This checks if the character after the comma is a number

       if entry[ind].isnumeric() == False:

If it is not a number, the print statement is executed

           print("Comma not followed by an integer")

           entry = input("Sentence: ")

If otherwise, the loop is exited

       else:

           break

This prints valid input, when the user enters a valid string

print("Valid Input")

Note that: entry = input("Sentence: ") is used to get input


Related Questions

Other Questions
whish game requires the exercise of waist Which two words are the closest synonyms?Press enter to interact with the item, and press tab button or down arrow until reaching the Submit button once the item is selectedA Departure and arrivalB Pranks and gagsC Unpredictable and expectedD Focused and successful Simplify: 90 - 5 (19 + 17-1-26) Work out the circumference of this circle.Take a to be 3.142 and write down all the digits given by your calculator.16.8 cm HELP WILL GIVE BRAINLIEST IF CORRECT: Which plants are usually the first to live in soil? a. Simple plantsb. Treesc. Plants that can support insect lifed. Flowers Will mark brainiiest help please An example of a relationship conflict isO a. fighting over what to watch on televisionO b.arguing over politicsO c. disagreeing over who gets to set the rulesO d. trying to convince a professor to change a grade Please help I'm not sure what the answers are -7 = 2x - 7A. 0B. 4C. Infinite SolutionsD. No solutions what is the answer to this question French Phase (1634-1648) What was the reasoning behind Catholic France aiding Protestant forces in the German and Sweden states? plz help The front panel of a cereal box has an area of 97 square inches. W The box has a total volume of 169.75 cubic inches. Which equation represents , the width of the box in inches? ______and____ are early tetrapods that do not have features unique to fish. Describe how these two species differ antaomically and what that means about where they each live. you are in talks to settle a potential lawsuit. the defendant has offered to make annual payments of 23000 29000 56000 and 84000 to you each year over the next four years respectively. all payments will be made at the end of the year. if the appropriate interest rate is 4.5 percent what is the value of the settlement offer today I NEED HELP ASAPPPP ILL GIVE BRAINLIESTTTTTT critically discuss the transport mechanisms across the membrane Why would allowing a plant to undergo photosynthesis 24 hours a day cause it to grow faster? write an informational article about Machu Picchu for a website that focuses on travel to places of historical interest. Write an article that explains to tourists the significance of Machu Picchu as a travel destination. Your articles must be based with ideas and information that can be found in the "Machu Picchu" passage set Please help! What is the population of people?? Answer and explanation please! no links :\ How does Troy reject Lyons in act 1 scene 4 in fences?