Related questions
My code doesnt pass this test case
How would I get my code to pass this test case?
Sample Input 3
this file, tests TEST a, b c erroneous cases TEST, a, b there should, only, be TEST, a b six lines, in, the, output TEST a b and it, should TEST a , b, c include this, one TEST a, b,, c
Sample Output 3
this file tests erroneous cases there should only be six lines in the output and it should include this one
Explanation 3
All of the lines beginning with TEST have some sort of syntax error, so they should be omitted from the output. The other lines have no errors, so they should be tokenized and output. The errors are as follows:
TEST a, b c: the comma between b and c is missing
TEST, a, b: there is an extra comma after TEST
TEST, a b: the comma between a and b is missing, and there is an extra comma after TEST
TEST a b: the comma between a and b is missing
TEST a , b, c: there is a space before the comma between a and b
def tokenize(line):
token_list = []
for token in line.split():
token_list.extend(token.strip(",").split(","))
return token_list
def main():
line_list = []
while True:
try:
line = input().strip()
if not line:
break
line_list.append(line)
except EOFError:
break
for line in line_list:
tokenized_line = tokenize(line)
if any("," in token for token in tokenized_line):
continue
print(" ".join(tokenized_line))
if __name__ == "__main__":
main()
Step by stepSolved in 3 steps
- Using Pythonarrow_forwardfari M File V Edit BDAN 410: DSS Analysis and Design home> 2.9: Math module @ho Bookmarks Window Help Sample output with inputs: 1.0 2.0 1.0 5.0 Points distance: 3.0 Run Assign point_dist with the distance between point (x1, y1) and point (x2, y2). The calculation is: Distance = SquareRootOf( (x2-x1)2 + (y2-y1)2). 401922.2754096.qx3zqy7 F2 2.9.3: Using math functions to calculate the distance between two points 1 import math 2 3 x1 = float(input()) 4 yl float(input()) 5 x2 = float(input()) 6 y2 float(input()) 7 8 Your solution goes here ''' 9 10 print('Points distance:', point_dist) = = 85 AUG 31 DU learn.zybooks.com F3 zy Section 2.9 - BDAN 410: DSS Analysis and Design 000 000 OOO THI I EzyBooks cat JINA A◄ DIIarrow_forwardThe input operation that appears just before a validation loop is known as thea. prevalidation read.b. primordial read.c. initialization read.d. priming read.arrow_forward
- Write a function that will read input into an array from a filearrow_forwardSummary In this lab, you write a while loop that uses a sentinel value to control a loop in a Python program. You also write the statements that make up the body of the loop. Each theater patron enters a value from 0 to 4 indicating the number of stars that the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. Instructions Make sure the file MovieGuide.py is selected and open. Write thewhile loop using a sentinel value to control the loop, and also write the statements that make up the body of the loop. Execute the program by clicking the Run button at the bottom of the screen. Input the following as star ratings: 0, 3, 4, 4, 1, 1, 2, -1 must be written with this code: """ MovieGuide.py This program allows each theater patron to enter a value from 0 to 4 indicating the number of stars that the patron awards to the Guide's featured movie of the week. The program executes...arrow_forwardI need help with this coding assignment.arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education