Skip to content

Anson Hon Fai Chow Random-Name-Generator Submission#26

Open
ansonchf wants to merge 5 commits intoalexnaylor99:mainfrom
ansonchf:main
Open

Anson Hon Fai Chow Random-Name-Generator Submission#26
ansonchf wants to merge 5 commits intoalexnaylor99:mainfrom
ansonchf:main

Conversation

@ansonchf
Copy link

No description provided.

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: ")
Copy link

@Alex-Polishchuk Alex-Polishchuk Apr 25, 2023

Choose a reason for hiding this comment

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

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
Copy link

@Alex-Polishchuk Alex-Polishchuk Apr 25, 2023

Choose a reason for hiding this comment

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

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)}")

Choose a reason for hiding this comment

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

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.

Choose a reason for hiding this comment

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

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:

Choose a reason for hiding this comment

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

Rather than a for loop you could write something like
print("Random names:\n" *name_list, sep='\n-')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants