Hi there! Here’s a challenge you might be able to solve AND HELP ME:
We have a group of 6 people, out of whom we need to choose a leader and AN ASSISTANT. You should do it so that the LEADER AND the ASSISTANT cannot be the same person.
I somehow tried, I just went like this:
import random
members = ['Max', 'John', 'Elsa', 'Mike', 'Asiia', 'Mosh']
leader = random.choice(members)
assist = random.choice(members)
print(f'The leader is {leader} and assistant is {assist}')
However, this is not ACCURATE, I mean the LEADER and ASSISTANT might be the same person according to this logic. What I would like to see is that if there’s a person named Max chosen to be the leader of the group, AND he cannot be an assistant as well. The code has to choose someone else.
I think this is the answer, you might have different codes tho’:
I got a leader
Once the leader’s chosen, I removed him/her from the members
And got the assistant:
import random
members = ['Max', 'John', 'Elsa', 'Mike']
leader = random.choice(members)
if leader:
members.remove(leader)
assist = random.choice(members)
print(f'The leader is {leader} and assistant is {assist}')