my question here Hi all. If I like to stop the program, what shall I use instead of : exit(0) ??
My code here:
My code here:
# file3.p # import sys rep = 'y' while (rep != 'n'): name = input('Enter the name of the file:') print("You entered: ", name) name = '/home/sylvain/' + name print("name is: ", name) try: fh = open(name, "r+") except IOError: #except ioerror: print("Cannot find file ") else: str = fh.read(10); print("Read String is : ", str) # Check current position position = fh.tell(); print("Current file position : ", position) # Reposition pointer at the beginning once again position = fh.seek(0, 0); str = fh.read(140); print("Again read String is : ", str) fh.close() input('Try for another file ? y/n ?') if rep=='n': exit(0) else: rep='y'
Moderator Larz60+: Removed formatting (A- button). Please do so in the future.