Building lottery numbers – Python

Lottery number:

This software selecting 6 random numbers between 1-37, the number can not go back twice

Used: import random , for

lotto.png

To copy or see all commands you can click on Details button below

 

 

#!/usr/bin/python
”’
author: Hopeless
task: lottery number , number can not return twice
”’
import random
#all numbers = range (1,37)
allnumbers = range(1,38)
winningNums = []

for i in range(1,7):
num = allnumbers[random.randrange(0,len(allnumbers))]
winningNums.append(num)
allnumbers.remove(num)

winningNums.sort()
print winningNums

 

 

Untitled.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s