subject

Python program You are given the following text file called Mytext. txt. Write a Python function called search_file that accepts the name of the file (i. e. filename) and a string to look for in the file (i. e. mystring) as parameters. The function then looks for mystring in the file. Whenever it finds the string in a line, it saves the line number and the text for that line in a dictionary. Finally, it returns the dictionary after reading all the lines in the file and populating the dictionary with all matching line numbers and line text. If an empty string or a blank string is passed as mystring then an empty dictionary is returned.
Sample Input: search_file("Mytext. txt","python")
Sample Input: search_file("Mytext. txt","")
Contents of Mytext. txt
Python is an interpreted, high-level, programming language.
Python is dynamically typed and garbage-collected.
Python was conceived in the late 1980s.
Python 2.0, was released in 2000.
Python 3.0, was released in 2008.
The interpreters are available for many operating systems.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Write a 3-4 page apa formatted paper comparing your organization’s it strategy with the best practices outlined in your course text. content should include, but not be limited to: developing and delivering on the it value, developing it strategy for the business value and linking it to business metrics. your paper should include an abstract and a conclusion and a reference page with 3-5 references
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Whats are the different parts of no verbal comunication, especially body language?
Answers: 3
question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
question
Computers and Technology, 24.06.2019 00:50
Which of the following is not a key player in the sale of travel products?
Answers: 2
You know the right answer?
Python program You are given the following text file called Mytext. txt. Write a Python function c...
Questions
question
Chemistry, 14.04.2021 09:30
question
Chemistry, 14.04.2021 09:30
question
Mathematics, 14.04.2021 09:30
question
English, 14.04.2021 09:30
question
Mathematics, 14.04.2021 09:30
Questions on the website: 13722361