moar PEP8
This commit is contained in:
parent
9f0bcbbac5
commit
715f926846
5 changed files with 69 additions and 66 deletions
|
@ -2,24 +2,25 @@
|
|||
from util import hook
|
||||
import random
|
||||
|
||||
|
||||
# used for tails: x heads: y
|
||||
def flip_simple(count):
|
||||
heads = 0
|
||||
tails = 0
|
||||
for x in range(count):
|
||||
c = random.randint(0,1)
|
||||
c = random.randint(0, 1)
|
||||
if c == 0:
|
||||
heads += 1
|
||||
else:
|
||||
tails += 1
|
||||
return [heads,tails]
|
||||
return [heads, tails]
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def coin(inp):
|
||||
".coin [amount] -- Flips [amount] of coins."
|
||||
|
||||
# checking for valid input. if valid input [count=inp], if invalid [return error], if no input [count=1]
|
||||
# checking for valid input. if valid input [count=inp],
|
||||
# if invalid [return error], if no input [count=1]
|
||||
if inp.isdigit():
|
||||
count = int(inp)
|
||||
else:
|
||||
|
@ -32,13 +33,13 @@ def coin(inp):
|
|||
return "Too many coins! Maximum is 200."
|
||||
# depending on the count, we use two different methods to get the output
|
||||
if count == 1:
|
||||
flip = random.randint(0,1)
|
||||
flip = random.randint(0, 1)
|
||||
if flip == 1:
|
||||
sidename = "heads"
|
||||
else:
|
||||
sidename = "tails"
|
||||
return "You flip a coin and get "+sidename+"."
|
||||
return "You flip a coin and get " + sidename + "."
|
||||
else:
|
||||
flips = flip_simple(count)
|
||||
return "You flip %s coins and get %s heads and %s tails." % (str(count), str(flips[0]), str(flips[1]))
|
||||
|
||||
return "You flip %s coins and get "\
|
||||
"%s heads and %s tails." % (str(count), str(flips[0]), str(flips[1]))
|
||||
|
|
Reference in a new issue