Skip to content

Instantly share code, notes, and snippets.

@chengxiao
Created April 16, 2013 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chengxiao/5393578 to your computer and use it in GitHub Desktop.
Save chengxiao/5393578 to your computer and use it in GitHub Desktop.
about roll
# today my lucky number
from random import choice
a =raw_input("Please enter /roll + number :")
def roll(c):
y = choice(range(c))
return y
if a.startswith("/roll") :
if a == "/roll":
print "Today Your Lucky Number Is %s"% roll(100)
raw_input("Enter anykey to Exit !")
elif "-" in a:
try:
b = a.split(" ")[1]
c =b.replace("-"," ").split()[0]
d =b.replace("-"," ").split()[1]
if int(c)>int(d):
print choice(range(int(d),int(c)+1))
elif int(c)<int(d):
print choice(range(int(c),int(d)+1))
except ValueError:
print "Sorry,Please Enter /roll + number"
raw_input("Enter anykey to Exit !")
else:
try:
b = a.split(" ")[1]
c = int(b)
print "Today Your Lucky Number Is %s"% roll(c)
raw_input("Enter anykey to Exit !")
except ValueError:
print "Sorry,Please Enter /roll + number"
raw_input("Enter anykey to Exit !")
else:
print "Sorry,Please Enter /roll + number!"
raw_input("Enter anykey to Exit !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment