Skip to content

Commit

Permalink
feat: add files for day-10
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-veeramalla committed Nov 8, 2023
1 parent cbe8862 commit 3ba1f93
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions Day-10/01-convert-string-to-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
folder_paths = input("Enter a list of folder paths separated by spaces: ").split()
10 changes: 10 additions & 0 deletions Day-10/02-main-construct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def main():
folder_paths = input("Enter a list of folder paths separated by spaces: ").split()
print(folder_paths)

# Print elements in the list
#for folder_path in folder_paths:
# print(folder_path)

if __name__ == "__main__":
main()
25 changes: 25 additions & 0 deletions Day-10/03-list-files-in-folders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os

def list_files_in_folder(folder_path):
try:
files = os.listdir(folder_path)
return files, None
except FileNotFoundError:
return None, "Folder not found"
except PermissionError:
return None, "Permission denied"

def main():
folder_paths = input("Enter a list of folder paths separated by spaces: ").split()

for folder_path in folder_paths:
files, error_message = list_files_in_folder(folder_path)
if files:
print(f"Files in {folder_path}:")
for file in files:
print(file)
else:
print(f"Error in {folder_path}: {error_message}")

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions Day-10/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Lists Part-2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
- List comprehensions.
- Nested lists and advanced list operations.
- Practice exercises and examples:
- Example: Parsing a complex configuration file with nested lists.
- Example: Print list of files in the list of folders provided

## Day 11: Working with Dictionaries and Sets
- Dictionaries and key-value pairs.
Expand Down

0 comments on commit 3ba1f93

Please sign in to comment.