Conversation
| if not user_names: | ||
| print('You have not entered any names. Please try again') | ||
| elif not re.search(r'^[a-zA-Z ]+$', user_names): | ||
| print('Names should only contain letters and be separated by spaces') |
There was a problem hiding this comment.
Verifying if the user has entered a name or not is important for input validation, so prompts for that. Using regex to check for specific character requirements in the entered list of names is a smart way to confirm that the input is clean.
mjoseph26
left a comment
There was a problem hiding this comment.
The program works as intended with good input validation to check if the user enters valid names and to check that they request a valid number of random names to be generated. It may be good to comments to more complex lines of code such as when you use random. sample so that it is easier for someone with little programming knowledge to understand. You follow the conventions for function and variable naming and the code overall is laid out in a logical manner. One thing you could try to do is check that the user is only allowed to enter in unique names although it won't affect the functionality of your application, since unique names will be selected anyway. It seems more logical for a user to provide a unique set of names to select one name from it, rather than allowing them to pass in the same name multiple times. Overall, great job with this exercise.
No description provided.