+ 1

Guys help me please

try: with open ("abc.txt") as f : print (f.read() ------ print ("Error")

20th Jul 2016, 11:20 AM
Hajji Soufiane
Hajji Soufiane - avatar
2 Answers
+ 1
I normally use Python 2.7 and this uses 3, so I might be wrong, but i can see a few things. 1. you need to invent everything inside your try 2. every try needs an except 3. Just fyi I haven't tested this on here but this should print error every time you run it on here because the file abc.txt isn't in the same directory as the web interpreter. If you run it on your computer in the same directory as abc.txt, it should print the contents of that file try: with open("abc.txt") as f: print(f. read()) except: print("error") #hopefully this helps
20th Jul 2016, 11:33 AM
Spencer
Spencer - avatar
0
thank you bro
20th Jul 2016, 11:34 AM
Hajji Soufiane
Hajji Soufiane - avatar