Created
April 16, 2013 05:26
-
-
Save chengxiao/5393578 to your computer and use it in GitHub Desktop.
about roll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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