Skip to content

Instantly share code, notes, and snippets.

@davidak
Created April 16, 2013 08:38
Show Gist options
  • Save davidak/5394375 to your computer and use it in GitHub Desktop.
Save davidak/5394375 to your computer and use it in GitHub Desktop.
Erzeugt zufällige Worte aus einer Liste, die nicht gleich sind.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import random
r = random.SystemRandom() # Uses /dev/urandom or Windows CryptGenRandom for better entropy
liste = ['Kartoffel', 'Flugscheibe', 'Erdbeben', 'Klospülung', 'Nanoroboter']
x = r.choice(liste)
print("x =", x)
y = r.choice(liste)
print("y =", y)
while x == y:
print("x = y !\n")
x = r.choice(liste)
print("x =", x)
y = r.choice(liste)
print("y =", y)
print("ok")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment