Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

aaa Notrpad | localhostaggaotebooks/Untitled27ipynb?kernel name-python2 Jupyter Untitled27 Last Checkpolnt: 8 minutes ago (unsaved changes) le Edit i InsertlKee Widgets Help File Edit Format View Help

image text in transcribed

aaa Notrpad | localhostaggaotebooks/Untitled27ipynb?kernel name-python2 Jupyter Untitled27 Last Checkpolnt: 8 minutes ago (unsaved changes) le Edit i InsertlKee Widgets Help File Edit Format View Help est a line 1 line 2 line 3 In [1 def open function(P): f-open(P, 'r') first_line f.readline) rest - f.readlines) these are the files itPatxt itPbbb. txt returnfirst line a rest f.close resta rest rest b rest In [21: a rest-open function aaa.txt') bbb Notepad File Edit Format View Help test b ine 1 line 2 h Traceback (nost cent call last) NameError ipython-input-2-d8eb85022996 in () ---> 1 a_rest-open_function(aaa.txt) line 3 line 4 ipython-input-1-2fc85f292f in open function(P) if P a.txt: rest-a rest if P 'bbb.txt: rest-b rest NameError : name . a rest' is not defined tnis tunctuon opens a rile takes tne top ine of the file and calls it first line and takes the rest of the file and calls it 'rest' i would like to be able to differentiate between the 'rest' that can be extracted from the two files. so if rest came from aaa.txt i call rest a_rest and if im loading it from bbb.txt i call it b_rest which i try to do with if p'aaa.txt' if p'bbb.txt': return first line, a rest resta rest rest-b rest however it doesnt work e_rest t-open function aaa.txt Traceback (most cent call last) > Nametrror in > 1 arest->en-function(' aaa.txt.) in open function(P) if p"aaa.txt'; rest - a rest if p "bbb.txt rest b rest NameError: name 'a rest' is not defined how can i make this open_function work the way i want

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago