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, 21.06.2019 18:00
Which if the following allows you to view and access important information about your documents all in one location
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
Martha is designing a single-player game. her manager suggests that she plan the design to incorporate future modifications. which principle of game design relates to planning for future modifications?
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Donnie does not have powerpoint. which method would be best for elana to save and share her presentation as is? a pdf a doc an rtf a ppt
Answers: 3
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. a company is currently focusing on creating specific management goals for itself. which level of maturity is the company demonstrating under the sse_ccm framework? a. performed informally b. planned and tracked c. quantitatively controlled d. well-defined e. continuously improving
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
Mathematics, 25.06.2019 11:30