+ 1
Why the values aren't getting stored in except.txt file!!
#except.txt has been created in the same folder!! print("Welcome To Division Calculator!!\n") with open('except.txt', 'a') as ex: while True: first = input('Enter 1st Number:\n(Enter Q to quit) ') if first == 'Q' or first == 'q': break second = input('Enter 2nd Number: ') try: over = int(first)/int(second) except ZeroDivisionError: print('You cant divide', first,'by 0\n') else: print('\n') print('Your answer is', over, '\n') ex.write(first + '\n') ex.write(second + '\n') ex.write(str(over) + '\n')
11 Respuestas
+ 4
Have you tried this: '\r\n' instead of '\n'
+ 6
If you open a file with >with open(...)< files don't have to be closed explicitely, this is done automatically.
+ 4
[Edited] On iOS the code works as expected. May be there is an issue that is platform dependend? Are you working on Windows?
-> Test on Windows was also successful.
+ 2
U should close file.
edit: ohhh with....
+ 1
Seems like it works to me:
https://code.sololearn.com/cq1h5l14X8lP/?ref=app
Try entering:
1
3
1
2
q
When you use "with" clause, it automatically takes care of closing the file when it's done.
You should end up with:
1
2
0.5
1
3
0.3333
stored in the except.txt file.
+ 1
Lohar it worked!! Thank You a lot!!
+ 1
only \n is not working and its working in your laptop!! this means my tablet's Python IDE has some problems!!
0
When i use \n in ex.write then its not storing the text in except.txt!!
0
Im working in tablet!!
0
i think theres problem in android!!
0
no let me try