How to select a number without replacement in python
<p>So I'm trying to make a mix and match between numbers here is my code</p>

<pre><code>import random

P1 = float(input("Person's name?")) 
P2 = float(input("Person's name?")) 
P3 = float(input("Person's name?"))

A1 = float(input("Activity?")) 
A2 = float(input("Activity?")) 
A3 = float(input("Activity?")) 

s = (A1, A2, A3)

cool1 = random.sample([A1, A2, A3],1)
cool2 = random.sample([A1, A2, A3],1)
cool3 = random.sample([A1, A2, A3],1)


print ("%s job is %s." %(P1, cool1))

print ("%s job is %s." %(P2, cool2))

print ("%s job is %s." %(P3, cool3))
</code></pre>

<p>The problem is that it is randomizing but it keeps repeating numbers like here</p>

<p>**</p>

<blockquote>
  <p>1.0 job is [4.0].
  2.0 job is [5.0].
  3.0 job is [4.0].</p>
</blockquote>

<p>**</p>

<p>What can I do to make it not repeat.
I'm using python 2.7.12</p>

<p>Also how can I use alphanumerical instead of float only.</p>

<p>write a class to pick a unique element from list<br>
1. permutations finds all unique elements <br>
2. rest can define new data and length of result<br></p>

<pre><code>from itertools import permutations
class PickOne( object ):
    def __init__(self,lst,l):
        self.lst    = lst
        self.visit  = set()
        self.l      =  l 
        self.lenght = self.number(l)
    def pick(self):
        if len(self.visit) == self.lenght :
            print 'run out numbers'
            return 
        res = tuple(random.sample(self.lst,self.l))
        while res in self.visit:
            res = tuple(random.sample(self.lst,self.l))
        self.visit.add( res )
        return res
    def reset(self,l,lst = None):
        if not lst:
            lst = self.lst
        self.__init__(lst,l)

    def number(self,l):
        return len( list(permutations(self.lst,l)) )
</code></pre>

<p>Example:</p>

<pre><code> a = PickOne([1,2,3,4],1)
    &gt;&gt;&gt; a.pick()
    (2,)
    &gt;&gt;&gt; a.pick()
    (1,)
    &gt;&gt;&gt; a.pick()
    (4,)
    &gt;&gt;&gt; a.pick()
    (3,)
    &gt;&gt;&gt; a.pick()
    run out numbers

    &gt;&gt;&gt; a.reset(2)
    &gt;&gt;&gt; a.pick()
    (3, 1)
    &gt;&gt;&gt; a.pick()
    (3, 4)
    &gt;&gt;&gt; a.pick()
    (2, 1)
</code></pre>

python python-2.7