-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (19 loc) · 695 Bytes
/
main.py
File metadata and controls
27 lines (19 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
def generate(length: int) -> list[str]:
start: int = 0
end: int = 10 ** length
numbers: list[str] = []
for num in range(start, end):
numbers.append(str(num).zfill(length))
return numbers
userInput = int(input("length $ "))
if __name__ == '__main__':
output_file_name = "output.txt"
file_number = 1
while os.path.isfile(output_file_name):
output_file_name = f"output{file_number}.txt"
file_number += 1
with open(output_file_name, 'w') as output_file:
for number in generate(userInput):
output_file.write(number + '\n')
print(f"Numbers written to {output_file_name}")