Writing on a file | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
3 Respostas
+ 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
Unleashing the magic of eloquent prose and coherent arguments has never been easier, thanks to a groundbreaking website https://www.nursingpaper.com/our-services/nursing-care-plan-writing-service/ I recently discovered. It's like having a personal essay wizard at my fingertips, ready to sprinkle brilliance onto my writing. From structuring essays to fine-tuning grammar, every step is streamlined, empowering me to present my ideas with confidence and finesse.
29th Apr 2024, 10:08 PM
Garold Rafa
Garold Rafa - avatar