Anson Hon Fai Chow Random-Name-Generator Submission#26
Open
ansonchf wants to merge 5 commits intoalexnaylor99:mainfrom
Open
Anson Hon Fai Chow Random-Name-Generator Submission#26ansonchf wants to merge 5 commits intoalexnaylor99:mainfrom
ansonchf wants to merge 5 commits intoalexnaylor99:mainfrom
Conversation
added 3 commits
April 25, 2023 00:13
main.py
Outdated
| Asks the user to input a list of names, validates them, removes duplicates and returns a list of valid names. | ||
| """ | ||
| # Ask the user to input a string of names separated by spaces | ||
| name_input = input("Please enter alpha names separated by spaces: ") |
There was a problem hiding this comment.
Perhaps leave comments in python style comments, comment about the code above or below rather than on the same line (ClarIfication)
main.py
Outdated
| # Ask the user to input a string of names separated by spaces | ||
| name_input = input("Please enter alpha names separated by spaces: ") | ||
| name_list = list(set(name_input.split())) # Split and remove duplicates | ||
| name_list = [name.title() for name in name_list if name.isalpha()] # Validate names |
There was a problem hiding this comment.
What do you mean validate? (Clarification)
| if 1 <= name_num <= len(name_list): | ||
| return name_num | ||
| else: | ||
| print(f"Please enter a number between 1 and {len(name_list)}") |
There was a problem hiding this comment.
Why will this be raised? And line 32, what is the difference? Perhaps a clarification
|
|
||
| def input_name(): | ||
| """ | ||
| Asks the user to input a list of names, validates them, removes duplicates and returns a list of valid names. |
There was a problem hiding this comment.
Perhaps you could add slightly more detail to your functions. Ie what sort of data type does this function accept and return? Could be useful for larger projects
main.py
Outdated
| # Select a random sample of names from the name_list and print them | ||
| random_names = random.sample(name_list, name_num) | ||
| print("Random names: ") | ||
| for n in random_names: |
There was a problem hiding this comment.
Rather than a for loop you could write something like
print("Random names:\n" *name_list, sep='\n-')
added 2 commits
April 26, 2023 12:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.