Open
Conversation
oar04
reviewed
Apr 25, 2023
| import random | ||
|
|
||
| # Asks user to input the names and format them to remove spaces and store in a list. | ||
| input_names = input('Enter a list of names separated by a comma (e.g. "Sam, John, Ben"): ') |
There was a problem hiding this comment.
Consider adding conditions to validate that the input is not empty.
| @@ -0,0 +1,31 @@ | |||
| import random | |||
|
|
|||
There was a problem hiding this comment.
The code has several procedures that implement its goal, these can perhaps be put into different functions, such as for for inputting the text, checking the numbers, generating the random names. This would be useful to be run several times if an extension to this project ever calls for it.
| num_names = int(input('Enter number of names you would like randomly shortlisted?: ')) | ||
| # Ensures the number entered is within the parameters of what has been entered. | ||
| if num_names < 0 or num_names > len(names_list): | ||
| print(f"You must choose a number between 1 and {len(names_list)}. Please enter a valid number considering the number of names inputted") |
There was a problem hiding this comment.
Stick with the same type for string quotes earlier you used ' ' and then it switches to " "
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.