Reading


#1



https://www.codecademy.com/en/courses/python-intermediate-en-OGNHh/0/4?curriculum_id=4f89dab3d788890003000096#


Traceback (most recent call last):
File "python", line 1, in
TypeError: bad operand type for unary +: 'str'

Oops, try again. Did you create a variable called my_file?


I expected this code to work perfectly, what is wrong?


my_file = open("output.txt", + "r")
print my_file.read()
my_file.close()


#2

my_file = open("output.txt", + "r")

There is no need to put + ?
general syntax we use..

open(file_name, mode_type)

More about it..
open function..


#3

lol thank you very much it works fine


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.