# Random: Python Challenge!

**URL:** <https://forum.codewithmosh.com/t/random-python-challenge/11213>\
**Category:** Python\
**Created:** [March 12, 2022, 10:08am UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213 "2022-03-12T10:08:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uLN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uln/32/3084_2.png) [@uLN](https://forum.codewithmosh.com/u/uLN)\
**Post date:** [March 12, 2022, 10:08am UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213/1 "2022-03-12T10:08:49Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![karu](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@karu](https://forum.codewithmosh.com/u/karu)\
**Post date:** [March 12, 2022, 3:41pm UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213/2 "2022-03-12T15:41:11Z")

</div>

stop this shit n do ur work

---

<div class="post-metadata">

**Author:** ![uLN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uln/32/3084_2.png) [@uLN](https://forum.codewithmosh.com/u/uLN)\
**Post date:** [March 12, 2022, 8:37pm UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213/3 "2022-03-12T20:37:31Z")

</div>

karu, this sh\*t is MY work.

Thank you, I have learnt a lot of things due to this question that I’d come with earlier.

---

<div class="post-metadata">

**Author:** ![uLN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uln/32/3084_2.png) [@uLN](https://forum.codewithmosh.com/u/uLN)\
**Post date:** [March 12, 2022, 9:29pm UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213/5 "2022-03-12T21:29:33Z")

</div>

I think this is the answer, you might have different codes tho’:

1. I got a leader
2. Once the leader’s chosen, I removed him/her from the members
3. And got the assistant:

```auto
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}')

```

---

<div class="post-metadata">

**Author:** ![AzharUddinSheikh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/azharuddinsheikh/32/5561_2.png) [@AzharUddinSheikh](https://forum.codewithmosh.com/u/AzharUddinSheikh)\
**Post date:** [March 13, 2022, 4:26pm UTC](https://forum.codewithmosh.com/t/random-python-challenge/11213/6 "2022-03-13T16:26:55Z")

</div>

@uLN there’s a lot a website where you can improve your logic **hackerrank** , **codechef** , **hackerearth** , **codestudio** , and finally **leetcode**
