Computers and Technology

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. student. py 1- def get list of_integers from_file(filename): int list - for line in open(filename).readlines (): int list. append (int (line)) return int list 12

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:00, bbysl15
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
image
Computers and Technology, 24.06.2019 00:30, bsonicx
The best definition of an idiom is a. a word or phrase that describes a noun b. a word or phrase describing a verb c. a phrase containing figurative language in which the word expresses a different idea from its exact meaning d. a phrase that compares two unlike objects or ideas
Answers: 2
image
Computers and Technology, 24.06.2019 07:00, AnaiyaKirksey8
You are most likely to automatically encode information about
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, jerry1496
If you want to delete an entire word at a time, which key should you press along with the backspace or delete key?
Answers: 1
Do you know the correct answer?
The function below tries to create a list of integers by reading them from a file. The file is expec...

Questions in other subjects:

Konu
Mathematics, 05.10.2019 03:00
Konu
Computers and Technology, 05.10.2019 03:00