Skip to content

Conversation

@zohrehKazemianpour
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

This PR contain implementing Shell tools cat, ls, and wc commands in Python.
This was my first time working with Python! The syntax felt familiar coming from JavaScript, though I had to get used to indentation being required and some differences like len() vs .length.

@zohrehKazemianpour zohrehKazemianpour added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 29, 2025
@LonMcGregor LonMcGregor added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jan 21, 2026
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start on this sprint's tasks, I have spotted a few areas where you could improve code further

numbered_line = f"{line_number:6}\t{line}"
numbered_lines.append(numbered_line)

print("\n".join(numbered_lines)) # LEVEL 3: inside if

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are doing the same thing in both if conditions, setting up a list of lines and then printing. Could you reduce some of the code duplication?

files = [f for f in files if not f.startswith('.')]

for file in files:
print(file) No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this program without the -1 option?

total_words += words
total_chars += chars

if args.lines:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test with multiple arguments given at once?

elif args.chars:
print(f"{total_chars:8} total")
else:
print(f"{total_lines:8}{total_words:8}{total_chars:8} total")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see the repetition in the structure of the code here? Could that be reduced somehow?

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants