-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrandom_team_generator.py
More file actions
42 lines (31 loc) · 985 Bytes
/
random_team_generator.py
File metadata and controls
42 lines (31 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Project: Random Team Generator
Author: Avanthika
Description:
Create a program that randomly divides people into teams.
Requirements:
1. Ask the user to enter names separated by commas.
2. Ask the user for the number of teams.
3. Randomly assign the names into teams.
4. Display the teams.
Sample Input:
Enter names: Alice,Bob,John,Maya,David
Enter number of teams: 2
Sample Output:
Team 1: Alice, John, David
Team 2: Bob, Maya
"""
def random_team():
import random
Names=input("Enter the names seperated by coma(,) : ")
namelist=Names.split(",")
n=len(namelist)
print("Number of members : ",n)
number_of_Teams=int(input("Enter the number of teams required : "))
random.shuffle(namelist)
teams=[[] for _ in range(number_of_Teams)]
for i,name in enumerate(namelist):
teams[i%number_of_Teams].append(name)
for i,term in enumerate(teams,start=1):
print(f"Team {i}:{','.join(term)}")
random_team()