Skip to content

Kseniia's project#24

Open
KseniiaEfremova wants to merge 2 commits intoalexnaylor99:mainfrom
KseniiaEfremova:main
Open

Kseniia's project#24
KseniiaEfremova wants to merge 2 commits intoalexnaylor99:mainfrom
KseniiaEfremova:main

Conversation

@KseniiaEfremova
Copy link

No description provided.

Copy link

@BirchAD BirchAD left a comment

Choose a reason for hiding this comment

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

Nice program, sorry for nitpicking!

import random


def get_list_of_users_names() -> list:
Copy link

Choose a reason for hiding this comment

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

May need more validations. User can enter an empty string or any punctuation as a name.

while len(users_list_of_names) < 2:
users_input = input("Input more than one name, please: ").split(",")
users_list_of_names = [name.strip() for name in users_input]

Copy link

Choose a reason for hiding this comment

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

May be better to turn into a set rather than a list at this point to remove any duplicate names entered by the user.

The function takes the list of names and number and returns random names from this list
"""

print(random.choices(list_of_names, k=number))
Copy link

Choose a reason for hiding this comment

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

Prints a list rather than formatting it into a string. May look nicer for the user if the output is structured.

This can also return the same index / name more than once? print(random.sample(list_of_names, k=number)) picks unique indexes.

main.py Outdated

# check a wrong entered number
if user_number >= len(list_of_names):
print("Your number should be less than the number of names in the list! Try again.")
Copy link

Choose a reason for hiding this comment

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

I think this goes over the pep8 character limit on a line? Could break after print( to a new line.

main.py Outdated
while True:

try:
user_number = int(input("Input the number of names, that you want to get: "))
Copy link

Choose a reason for hiding this comment

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

I think this goes over the pep8 character limit on a line? Could break after int( to a new line.

import random


def get_list_of_users_names() -> list:
Copy link

Choose a reason for hiding this comment

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

Function name could be more specific based on pep8 standards. i.e. including that it's a user input function.

return users_list_of_names


def get_number_of_names(list_of_names: list) -> int:
Copy link

Choose a reason for hiding this comment

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

Function name could be more specific based on pep8 standards. i.e. including that it's a user input function.

return user_number


def get_random_names(list_of_names: list, number: int):
Copy link

Choose a reason for hiding this comment

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

Function name could be more specific based on pep8 standards. i.e. select_random_names_from_list

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.

3 participants