+ 8

What's wrong with this code ? 😕

I wrote this code as my first try to make my first files rewrite function 😃 and it tells me in line 9 the name 'project' is not defined 😑 so how can I define it ? 😕 here's the code : def file_rewrite(filename): file = open(filename,"w") file.write("hello") file.close() myfile = open("project.txt","w") myfile.close() print(file_rewrite(project.txt)) file_opening = open("project.txt","r")

29th Sep 2017, 5:44 PM
warlord
warlord - avatar
4 Answers
+ 12
Missing " " ?
29th Sep 2017, 5:58 PM
Tashi N
Tashi N - avatar
+ 11
Tashi is right. You're missing the quotes in filename argument.
29th Sep 2017, 6:06 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
thank you all for replying I thought it didn't need the quotes cause it's a function 😐
29th Sep 2017, 8:20 PM
warlord
warlord - avatar
+ 1
i think there is missing quotes " "
27th Mar 2018, 12:59 PM
Lika Julayidze
Lika Julayidze - avatar