Answered step by step
Verified Expert Solution
Question
1 Approved Answer
printing from a file in python ionly want to make changes to this i wish to define in my function what the first line is
printing from a file in python ionly want to make changes to this i wish to define in my function what the first line is and what the rest of the file is. that way i can call the function and say print(first_line) or print (rest) and it can just print it there i have made print(first_line) work. t doing the same thing for print(rest) doesnt work i want "rest" to be all of the file EXCEPT for the first line and to be able to print it in the same way dot open tunctien (: f upen(b,' first line-f.reodline() return first linc rest-f.readlines( return r25 f.clcsc i can print the first line i only want to change my function In 11: def open function (b): first-line f .raad, ina() relurni finl 1ine ???? is this not right??? #### not this rest-f.realines( apen function bbb.txt test line 1 1ina 2 print( irst-line ) print(rest) test b line printifirst_1incj print(rest) Tracehack (mast recent call last) ipython-input-4-52f91cdir7> in codule0 test b line 1 print(first line) --> 4 print (rest NancError: nancrst is not delincd
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started