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
Select all of the reasons Windows 95 increased the popularity of Windows.
NISA [10]

Answer:

The following lead towards the reason why Windows 95 become popular:

<em>enhanced multitasking  </em>

<em>information could be accessed and shared faster </em>

<em>an updated file management system </em>

<em>a finder included </em>

<em>backward compatibility </em>

<em></em>

Explanation:

5 0
3 years ago
What are the requirements of a data dictionary ?
rodikova [14]
While these are the core elements of a data dictionary, it's not uncommon to document additional information about each element, which may include the source of the information, the table or concept in which the attribute is contained, the physical database field name, the field length, and any default values.
8 0
3 years ago
Read 2 more answers
What was the attitude of the U.S. Senate towards the Treaty of Versailles, and why did they have that attitude?​
Arte-miy333 [17]

Answer:

in 1919 the Senate rejected the Treaty of Versailles, which formally ended World War I, in part because President Woodrow Wilson had failed to take senators' objections to the agreement into consideration. They have made the French treaty subject to the authority of the League, which is not to be tolerated. hope it helps in someway ig idk

Explanation:

8 0
3 years ago
What is the WiFi signal strength in different iPhone models?
Anika [276]
This is a really good question! WiFi signal strengths depend on the model of the WiFi receiver (which is in the iPhone) and the quality of the router sending out the signals.
8 0
3 years ago
While inspecting an element in the DOM on my website using the Chrome Devtools I accidentally deleted the DIV that had all my au
Kobotan [32]

Answer:

Refresh the page, it will reset all the underlying code.

Explanation:

Inspecting an element is essential for web developers in building websites faster and better. The Chrome DevTools is a powerful tool that is integrated into the Chrome browser to assist developers in on-the-go website troubleshooting.

Editing codes in the Chrome DevTools console does not affect the source code of the website hosted on a server, it just provides instant editing functions for troubleshooting or website enhancement.

Therefore, refreshing the page, re-loads the website again from its database which will show the unedited website. In our scenario, after refreshing the page, all the deleted DIV that contains all the authentication will reappear again.

4 0
3 years ago
Other questions:
  • What type of restrictions may be placed on your license?
    7·1 answer
  • Generate the requested sets using only set builder notation and the provided sets. Some problems may require you to build one or
    15·1 answer
  • Need this!!
    11·2 answers
  • If str 1 and str2 are both Strings, which of the following expressions will correctly
    13·1 answer
  • An adiabatic capillary tube is used in some refrigeration systems to drop the pressure of the refrigerant from the condenser lev
    15·1 answer
  • Different between desktop application and web application ?​
    9·1 answer
  • Not every organization integrates with the Internet, but all use some or most of the technology that gave rise to it.
    15·1 answer
  • You are implementing a new application control solution. Prior to enforcing your application whitelist, you want to monitor user
    5·1 answer
  • Write a program that gets three input characters which are user's initials and displays them in a welcoming message. Then gets i
    12·1 answer
  • question 1 scenario 1, question 1-5 you’ve just started a new job as a data analyst. you’re working for a midsized pharmacy chai
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!