Question: opening a file with python is it possible to get the function to open a file of my choosing tn [1 def open functian (b):
opening a file with python
is it possible to get the function to open a file of my choosing
tn [1 def open functian (b): i am trying to define a function that can open either aaa.txt or bbb.txt f-opent'br for i in range [1): function i had hoped i could choose which file it open like so first_liref.readlise) rest-f.readlires) fcloae def open function (b): In 2): openfuncticn b.txt' print(first 1ine) trying to use function f-openf"b', 'r') open function (bb5.txt') print(first line) Traceback (ost roceat call last) lpython-1sput-2-eb53d1d1532a> optn function (ebb.txt 1n nodules() print(first_line) and then it would enter b as whatever i input here def apen furetion (b) pen'b' 4 for in range (1): first_line-f.readline File:NotFoanError ; [Ermo 2] such file or directory: . b however... i dont think thats how it works
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
