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
Helen [10]
3 years ago
5

The function below tries to create a list of integers by reading them from a file. The file is expected to have a single integer

per line and the code works correctly in that case. If any of the lines don't contain just an integer, than this code fails. Fix this code so that it ignores any lines that don't contain integers instead of raising an exception. Do this with try/except blocks. Your code should still return the list of integers from the lines that contain integers.

Computers and Technology
1 answer:
Setler [38]3 years ago
4 0

Answer:

Check the explanation

Explanation:

def get_list_of_integers_from_file(filename):

int_list=[]

for line in open(filename).readlines():

try:

int_list.append(int(line))

except:

continue

return int_list

print(get_list_of_integers_from_file('file.txt'))

 

File.txt:

Kindly check the output below.

You might be interested in
Which computer career field enables you to create and design interactive multimedia products and services?
rjkz [21]
I think its graphic design
3 0
4 years ago
If you have a charger that’s not from Apple, then could that damaged your iPhone or not?
MakcuM [25]
It could. But good ones won't.
7 0
3 years ago
After fixing the format of her subheadings, she notices that she misspelled the name of one of the famous people she featured in
GREYUIT [131]

Jemina can go to the editing command group and use the find and replace feature in order to correct her mistake in an efficient manner. Thus, the correct option for this question is A.

<h3>What is the Editing command?</h3>

The editing command may be defined as a type of command which is utilized to make corrections or modifications in an existing file. The line editor is a lower form of the ex-editor and is planned for beginners and is launched by the edit command.

By using the MS-DOS text editor also you are capable to edit, explore, construct, and adjust any text file on your computer. By becoming efficient and comfortable with the editor, people may recognize the more complicated features of the other editors as well.

Therefore, the correct option for this question is A.

To learn more about the Editing command, refer to the link:

brainly.com/question/3668326

#SPJ1

7 0
1 year ago
Read 2 more answers
A file type that allows a document to be read on most computers is a _____.
Travka [436]
Txt

Note, only Windows really cares about the file extension. OSX's Finder will use it if Finder can't find a creator in the file metadata to select an app when double clicking on it. Linux and Unix don't care.
7 0
4 years ago
There are two major types of wireless networks that are popular today among users. These networks are Wi-Fi and ____
Viefleur [7K]

Answer:

That would be Bluetooth

Explanation:

As Bluetooth is the most widely used network. It is used to operate many things, such as:

Headphones

Speakers

Remotes

etc.

5 0
3 years ago
Other questions:
  • While designing a website, a(n) ____ allows you to identify the specific amount of space used on a particular page before it con
    15·2 answers
  • A​ ___________ identifies the content and purpose of the​ visual, along with whatever label and number​ you're using to refer to
    15·1 answer
  • Write a function that computes the average and standard deviation of four scores. The standard deviation is defined to be the sq
    15·1 answer
  • Which descriptions offer examples of Correction Services workers? Select all that apply.
    8·1 answer
  • As a student, why do you need to know and follow the steps printing a <br><br>document?​
    6·2 answers
  • What is a computer system model and explain?
    10·1 answer
  • Which command will provide us with a list of the available internal commands (commands that are part of Command Prompt, such as
    7·1 answer
  • What are some areas in Computer Science that make use of multivariate statistical testing or MCM methods? Explain why they are u
    14·1 answer
  • ________ can be written only once. The data cannot be erased or written over once it is saved.​
    9·1 answer
  • Is nanotechnology is good or bad? and why?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!