I don't have much to say on the style side, which is good. I think my only real comment would be that I personally find using newline characters simpler than triple-quotes for multiline strings, especially when you just want to make sure of the spacing between lines.
I like that you're using randint
for the rolls, instead of randrange
or some other structure: it's inclusive for start and stop, and that exactly matches the real-world function that you're recreating here, so there's no need to fudge the parameters or the results with +1.
Design-wise, I would split the front-end stuff, which takes input from the user and gives back information, from the actual dice-rolling. That would let you reuse the dice roller for other purposes (off the top of my head, a random treasure generator), extend the interface logic with additional kinds of functionality, or rework your logic without ripping apart the whole structure.
And as long as you're doing that, think bigger -- 'I need to roll a d20' is just a single case of 'I need to roll some dice', and that problem's not much harder to solve. So here's how I would approach it:
def play():
"""
This function is just the user interface.
It handles the input and output, and does not return anything.
"""
name = raw_input('Please Type in your name > ')
print "\nHello {}, & welcome to the Random D20 Number Generator by Ray Weiss.\n".format(name)
print "Please type your rolls as 'NdX' (N=number of dice, X=size of dice), or 'Q' to quit.\n"
while True:
dice = raw_input("What dice do you want to roll? ").lower()
if dice == 'q':
break
else:
try:
number, size = dice.split('d')
results = roll_dice(int(number), int(size))
except ValueError:
# This will catch errors from dice.split() or roll_dice(),
# but either case means there's a problem with the user's input.
print "I don't understand that roll.\n"
else:
print 'You rolled {!s}: {!s}\n'.format(sum(results), results)
print "\nThank you {} for using the D20 RNG by Ray Weiss! Goodbye!\n".format(name)
def roll_dice(number, size):
"""
number: any int; < 1 is allowed, but returns an empty list.
size: any int > 1
Returns: a list with `number` elements, of dice rolls from 1 to `size`
"""
from random import randint
return [randint(1, size) for n in range(number)]
One functionality you would probably want to add would be modifying roll_dice()
to accept a modifier (+ or - some amount). And if you really want to get fancy, you can start checking the results to highlight 1s or 20s, or other roll results that have special values in your game.