# [Tutor] question

Prayash Bhuyan bhuyanprayash18 at gmail.com
Wed Apr 12 04:41:07 EDT 2023

```import random

# list of names
names_list = ["ayush","bhargav","akankhya","prayash"]

# dictionary to keep track of numbers assigned to names
#numbers_dict = {}

# prompt the user for a name and randomly assign a number to the name
for name in names_list:
while True:
user_input = input("Enter name: ")
if user_input.casefold() in names_list:
group = random.randint(1, 4)
#numbers_dict[user_input] = number
break
else:
print("Name not in list. Please try again.")

this is my code i am writing a code where the computer asks the user for a
name and if the name is in the list then it randomly assigns a number which
in this case is the group number ..Now suppose I have 20 members in the
lsit and I want to form four groups with five members in each group ..now a
particular random number between 1 and 4 should only appear 5 times and not
more than that because if that occurs members will not be equally divided
in the group ..thats what i want...and it is not an assignment it's
something that i am doing to satisfy my curiosity

On Wed, Apr 12, 2023 at 1:21 PM dn via Tutor <tutor at python.org> wrote:

> On 12/04/2023 18.28, Prayash Bhuyan wrote:
> > I know how to generate random numbers using random function but I want to
> > know how do i generate random numbers say between (1,5) where each random
>
> Do you know how to write a loop in Python?
> Do you know about dict[ionary]s?
> Are we talking about integers or real numbers?
> (or suites in a deck of cards)
> Is this a course-assignment?
>
> then we will be able to discuss what's missing or what might be added.
>
> --
> Regards,
> =dn
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
```