10000 completed challenge · RobACurtis/Learning-Python@d48eb1f · GitHub
[go: up one dir, main page]

Skip to content

Commit d48eb1f

Browse files
Rob CurtisRob Curtis
authored andcommitted
completed challenge
1 parent 945aa54 commit d48eb1f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Ch3 - Files/challenge.py

Lines changed: 8 additions & 3 deletions
< 8000 td data-grid-cell-id="diff-d92a97c80daa8f76954beb906fdc017674f0336c9dcb773fdbf5523c21d6f8e9-24-26-2" data-line-anchor="diff-d92a97c80daa8f76954beb906fdc017674f0336c9dcb773fdbf5523c21d6f8e9L24" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionLine-bgColor, var(--diffBlob-deletion-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell left-side-diff-cell border-right left-side">-
myfile.write(x + '\n')
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# define a function
55
# use listdir() to return a list containing the names of the entries in the directory given by path
66
# use mkdir() to create a directory for the new .txt file
7+
78
import os
89
from os import path
910

@@ -16,12 +17,16 @@ def main():
1617
myfile = open("./results/results.txt", "w+")
1718
bytes = 0
1819
for x in list:
19-
bytes += os.path.getsize(x)
20+
if os.path.isfile(x):
21+
bytes += os.path.getsize(x)
2022
myfile.write('Total bytecount: ' + str(bytes) + '\n')
2123
myfile.write('Files list: \n')
22-
myfile.write('------------------- \n')
24+
myfile.write('---------------- \n')
25+
2326
for x in list:
24
27+
if os.path.isfile(x):
28+
myfile.write(x + '\n')
29+
2530

2631
myfile.close()
2732

Ch3 - Files/results/results.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
Total bytecount: 22887
2-
Files list:
3-
-------------------
1+
Total bytecount:22881
2+
Files list:
3+
--------------
44
.DS_Store
55
ospathutils_finished.py
66
shell_start.py
7-
sfdfg
87
testzip.zip
98
files_finished.py
109
textfile.txt.bak

0 commit comments

Comments
 (0)
0