0

Trying to solve filling up with up numbers in intermediate python

Don't know what to do from here N = int(input()) file = open("numbers.txt", "w+") file.write("\nN") file.close() f = open("numbers.txt", "r") print(f.read()) f.close()

31st Mar 2021, 9:38 AM
Simisola Osinowo
Simisola Osinowo - avatar
7 ответов
0
I assigned a variable to 1 and used a while loop to write the variable and a new line to the file and increment the variable by 1. If you need I can show you my code but I think you got this
31st Mar 2021, 10:14 AM
Alexander Crum
Alexander Crum - avatar
0
Sorry can you show me
31st Mar 2021, 10:15 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
N = int(input()) file = open("numbers.txt", "w+") x = 1 while x <= N: file.write(str(x) + "\n") x += 1 file.close() f = open("numbers.txt", "r") print(f.read()) f.close() No problem :)
31st Mar 2021, 10:21 AM
Alexander Crum
Alexander Crum - avatar
0
Thanks
31st Mar 2021, 10:23 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
Can you help me with the book club practice
31st Mar 2021, 10:29 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
You are given a books.txt file, which includes book titles, each on a separate line. Create a program to output how many words each title contains, in the following format: Line 1: 3 words Line 2: 5 words ... Make sure to match the above mentioned format in the output. Alexander Crum
31st Mar 2021, 11:19 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
Alexander Crum it worked thanks Any idea on balanced parenthesis in python data structure
31st Mar 2021, 12:45 PM
Simisola Osinowo
Simisola Osinowo - avatar