Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

opening a file with python ide like to get this function to open any file of my

ID: 3723473 • Letter: O

Question

opening a file with python

ide like to get this function to open any file of my chosing

ie i just want to be able to type
open_function(aaa.txt)

or

open_function(bbb.txt)


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

Explanation / Answer

# quotations are important here for filename