Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am required to have everything on one line and no spaces. My code is not passing because there is the word Elon Musk on

image text in transcribed

I am required to have everything on one line and no spaces. My code is not passing because there is the word "Elon Musk" on the second line. The code is working properly as far as the spaces are concerned. I have taken them out and left the punctuation in tact per the instructions. I just can't get the new line to strip.

Question 1 Write a program that reads a file called test.txt and prints out the contents on the screen after removing all spaces and newlines. Punctuations will be preserved. For example, if test.txt contains: This is a test file, for chapter 06. This a new line in the file! Then, your program's output will show: Hint: Consider using the 'strip[l and 'replace[l functions. Thisisatestfile,forchapter06.Thisanewlineinthefile! Automated Results Run Tests code.py* New Full Screen 1 file open("test.txt","") test FAILED 3 for line_string in file: 4 line string line string.strip("In") 5 line_string line_string.replace(" ", "*) print (line string)

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions