![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 27.04.2021 15:20 nanett0226
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](/tpl/images/cats/User.png)
Answers: 3
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 03:40
Hello my name is mihai and i need your : )i have to do a python project in computer science and i’m really busy with my mocks this period of time besides this i’m not good at coding so could someone pls pls pls sort me out ? i actually beg ; ))
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 00:50
Which player type acts on other players? a. killer b. achiever c. explorer d. socializer
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 07:00
Why would a business likely use a java applet - to back up their data files for the business - to create a program that a customer can launch in their web browser - to create music on a powerpoint presentation - to organize files on their company directory
Answers: 3
You know the right answer?
Python program
You are given the following text file called Mytext. txt. Write a Python function c...
Questions
![question](/tpl/images/cats/mat.png)
Mathematics, 18.03.2021 02:00
![question](/tpl/images/cats/himiya.png)
Chemistry, 18.03.2021 02:00
![question](/tpl/images/cats/mat.png)
Mathematics, 18.03.2021 02:00
![question](/tpl/images/cats/biologiya.png)
Biology, 18.03.2021 02:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/biologiya.png)
Biology, 18.03.2021 02:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 18.03.2021 02:00
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 18.03.2021 02:00
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/istoriya.png)
History, 18.03.2021 02:00
![question](/tpl/images/cats/biologiya.png)
Biology, 18.03.2021 02:00
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/istoriya.png)
History, 18.03.2021 02:00
![question](/tpl/images/cats/mat.png)
Mathematics, 18.03.2021 02:00