Python: Random without repetition, but in def
Question: I don't know how in def I can randomize sentences without repetition.

    
    
    def yellowJeden(x,m):
        if m <= 25:
            zd1 = "Juz na samym poczatku meczu "+ x.strip() + " dostal"
            zd2 = "Juz w " + str(m) + ". minucie meczu zawodnik druzyny "+ druzyna1 + " dostal zolta kartke. "+ x.strip() + " sfaulowal swojego przeciwnika."
            zd3 = x.strip() + " juz w poczatkowych minutach meczu otrzymal zolta kartke za nieczyste zagranie. Sfaulowal on zowodnika druzyny przeciwnej. "
    
            zolta1 = [zd1, zd2, zd3]
            zolta1Index = random.randint(0, len(zolta1)-1)
            print zolta1[zolta1Index]
            zolta1.remove(zolta1[zolta1Index])
    
    def akcja():
        a = line.split(',')
        min = int(a[1])
        if a[2] == ' yellow1':
            yellow1 = a[3]
            yellowJeden(yellow1, min)
        elif a[2] == ' yellow2':
            yellow2 = a[3]
            yellowDwa(yellow2, min)
    
    for line in fh:
        if line.startswith('1.'):
            akcja()
        elif line.startswith('2.'):
            akcja()
        elif line.startswith('3.'):
            akcja()
    

It's more complicated. I don't want to write every sentence.


Answer: Are you looking for something like this?

    
    
    >>> import random
    >>> def ShuffleSentences():
    ...     sentences = [ "First sentence", "Second sentence", "Third sentence", "last sentence"]
    ...     random.shuffle(sentences)
    ...     for s in sentences:
    ...         print s
    ...
    >>> ShuffleSentences()
    Second sentence
    last sentence
    Third sentence
    First sentence
    >>> ShuffleSentences()
    Second sentence
    First sentence
    Third sentence
    last sentence
    >>> ShuffleSentences()
    Second sentence
    Third sentence
    First sentence
    last sentence
    >>>
    

