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
The central processing unit​ (cpu) works in conjunction with​ ________ to perform processing.
Mama L [17]
The central processing unit​ (CPU<span>) </span>works in conjunction<span> with​ </span><span>______ to perform processing</span>
4 0
3 years ago
2. Sometimes, validating the HTML code for a web page will help you debug an application, because a. the page won’t run in a bro
aleksandrvk [35]

Answer:

Option c. you can be sure that a validated page will work correctly in a browser

Explanation:

A faulty HTML codes can result in various types of unexpected error when running the web page in different platforms or browsers. This will cause an inconsistent style or layout. HTML code validation can check if the code adopt the standard tag and structure. A validated HTML code can guarantee a web application running smoothly in different browsers and always present consistent web page layout to users. HTML code validation has become part of the standard workflow before a web page go live in internet.

4 0
3 years ago
Which careers have the highest minimum experience requirement?
Dafna11 [192]
(B) CIO, because they make $308,561 per year and it wouldn’t be A cause they only make $140,265 per year nor would C .
8 0
3 years ago
In contrast to data in a database, data in a data warehouse is described as subject oriented, which means that it _____.
jonny [76]

Answer:

focuses on a certain subject

Explanation:

it means that it focuses on that one subject and none others

Hope it helps c:

6 0
2 years ago
And, Or, Not are examples of:
yanalaym [24]
Boolean operators it is
all the best
5 0
3 years ago
Other questions:
  • If you receive an increase in pay, how will that affect your payroll deductions?
    8·1 answer
  • Find and record a set of instructions containing a repetition clause (e.g., instructions on a shampoo bottle, a recipe, etc.). H
    11·1 answer
  • Most keyboards today are in a
    8·1 answer
  • Shortcuts will help you complete spreadsheet tasks more efficiently.
    12·1 answer
  • What are some fun games to play on you phone?
    12·2 answers
  • When working with arrays, most programming languages perform ________, which means they do not allow programs to use invalid sub
    5·1 answer
  • Select the correct answer.
    11·1 answer
  • How does a search engine use algorithms to provide search results?
    15·2 answers
  • Complete the steps for saving a presentation as a poi file,
    14·1 answer
  • Function of dobji dzong​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!