0

Writing on a file

Please i need help with the exercise of the file writing lesson: n = int(input()) file = open("numbers.txt", "w+") #tu código va aquí for i in range(n): file.write(str(i+1)+"\n") file.close f = open("numbers.txt", "r") print(f.read()) f.close() I don’t have any output. Why is this wrong? What am i doing wrong? Thanks for your help

7th Jun 2022, 8:56 PM
Mabel Zavala Moreira
4 odpowiedzi
+ 6
file.close needs the parentheses file.close() Maybe this was causing the issue?
7th Jun 2022, 9:05 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
🤦🏻‍♀️ yes that was the problem Apollo-Roboto thanks a lot 🙏
8th Jun 2022, 12:41 AM
Mabel Zavala Moreira
0
Code looks fine, but it seems like the file isn't properly saving or opening in the correct mode. If you’re struggling with this, you could always write my custom essay https://writemycustomessay.com/ to get expert help on debugging and improving your code. Make sure you double-check the file path and mode to ensure everything is being written correctly
27th Apr 2025, 4:10 PM
tom ferna
tom ferna - avatar