1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lara [203]
3 years ago
10

Write a program that reads a file that contains only integers, but some of the integers have embedded commas, as in 145,020. The

program should copy the information to a new file, removing any commas from the information. Do not change the number of values per line in the file.
Computers and Technology
1 answer:
PtichkaEL [24]3 years ago
4 0

Answer:

with open("integer_file.txt", "r") as file:

   book = file.read().strip()

   pages = book.split(" ")

   for page in pages:

       if "," in page:

           comma_rm = page.replace(",","")

           print(comma_rm)

       else:

           print(page)

Explanation:

The python program opens a text file (Assuming the file contains only integers but are in string form eg: 5 in '5' for string), reads the whole content of the file as a string, splits it to a list of strings and iterates through to remove commas in the number string and display the elements.

You might be interested in
Define a function in Scheme (or relation in Prolog) that checks whether a set of elements (represented as a list) is a subset of
mafiozo [28]

Answer:

subset([],[]).

       subset([X|L],[X|S]) :-

           subset(L,S).

       subset(L, [_|S]) :-

           subset(L,S).

Success:

     subset([1,3], [1,2,3]).

     subset(X, [1,3,4]).        % error handling to compare sets in a given order

Fail:

     subset([2,1], [1,2,3]).   % compares in a different order from the first.

Explanation:

The function "Subset" in the source code above accepts two sets, then checks if the first set is a subset of the second. The code returns true if the condition is met.

4 0
3 years ago
Write a class named Movie that has fields to hold the following data: Title Studio Name Year produced Rating In the Movie class,
rewona [7]

Answer:

Explanation:

don't know

3 0
2 years ago
Which of the following devices electronically sorts mail by ZIP code?
irina [24]
The answer is OCR or optical character reader.
This device is used to electronically sorts mails by zip code.
This device reads texts from the papers or documents, images and pdf files,  and then convert it into editable file.
7 0
3 years ago
What does the merge & center button in the alignment group on the home tab do?
e-lub [12.9K]
A merge and center does this;
if you have created a table,it just centers a sentance
6 0
3 years ago
Knowing how to develop an outline well is very easy, and most students can create quality outlines in one attempt. Please select
vovangra [49]

Its False, just took the test I chose true buh it told me I was wrong so iss gotta be false.

8 0
4 years ago
Read 2 more answers
Other questions:
  • An example of a primary collision factor is
    6·2 answers
  • An array created during the execution of a program is called a(n) ____ array.
    11·1 answer
  • What should you do if a dialog box covers an area of the screen that you need to see?
    10·2 answers
  • Is a router on the local network that is used to deliver packets to a remote network?
    15·1 answer
  • Write code that prompts for three integers, averages them, and prints the average. Make your code robust against invalid input;
    7·1 answer
  • Write a function that receives three StaticArrays where the elements are already i n sorted order and returns a new Static Array
    11·1 answer
  • Why does the randomNumber function only use whole numbers between 0 and 1 (basically, 0 and 1)?
    13·1 answer
  • Which of the following bit value represent -5 in two's complement notation?
    5·1 answer
  • Need help completing this coding assignment.
    11·1 answer
  • Computers are not automatic they need human to operate.(true or false)​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!