This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 18th, 2013  |  syntax: Python  |  size: 0.83 KB  |  views: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     import random as rand
  2.     import sys
  3.     def getNumDice(string):
  4.         number=""
  5.         for i in range(len(string)):
  6.             if string[i]=='d':
  7.                 break
  8.             else:
  9.                 number+=string[i]
  10.         return int(number)
  11.     def getDieSides(string):
  12.         final=""
  13.         for i in range(len(string)):
  14.             if string[i]=='d':
  15.                 i+=1
  16.                 for n in range(i, len(string)):
  17.                     final+=string[n]
  18.                 break
  19.         return int(final)
  20.     def getRoll(string):
  21.         output="Rolls: "
  22.         for i in range(getNumDice(string)):
  23.             output+=str(rand.randint(1, getDieSides(string)))
  24.             output+=" "
  25.         print output
  26.     for i in range(1, len(sys.argv)):
  27.         print sys.argv[i]
  28.         getRoll(sys.argv[i])
clone this paste RAW Paste Data