Skip to content

Random Name Generator - Furqan#31

Open
FurqanA1 wants to merge 1 commit intoalexnaylor99:mainfrom
FurqanA1:main
Open

Random Name Generator - Furqan#31
FurqanA1 wants to merge 1 commit intoalexnaylor99:mainfrom
FurqanA1:main

Conversation

@FurqanA1
Copy link

No description provided.

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

Choose a reason for hiding this comment

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

Consider adding conditions to validate that the input is not empty.

@@ -0,0 +1,31 @@
import random

Copy link

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Stick with the same type for string quotes earlier you used ' ' and then it switches to " "

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