# EXTREME NOOB, lists?

Quinn Dunkan quinn at baht.ugcs.caltech.edu
Sat Sep 2 04:55:22 CEST 2000

```On Fri, 1 Sep 2000 21:30:03 -0400, skeetor <skeetornospam at bellsouth.net> wrote:
>Ok, apparently I was unclear.  This language is still unfamiliar to me...
>I want to combine all the elif statements with the if statement to say.
>"if a is equal to any number in list x then print a's range"
>
>here's what I have.
>
>a = input ("which dice: ")
>def dice_numbers(a):
>     a = a + 1
>     b = range(1, a)
>     print b
>if a == 4:
>     dice_numbers (a)
>elif a == 6:
>     dice_numbers (a)
>elif a == 8:
>     dice_numbers (a)
>elif a == 10:
>     dice_numbers (a)
>elif a == 12:
>     dice_numbers (a)
>elif a == 20:
>     dice_numbers (a)
>elif a == 100:
>     dice_numbers (a)
>else:
>     print ("try again")

if a in [4, 6, 8, 10, 12, 20, 100]:
...

But what if you want 1d15?
Or meta-dice which roll 1d(2d4) ?

import string, random
def roll(s):
times, die = map(int, string.split(s, 'd'))
r = 0
for i in range(times):
r = r + random.choice(range(die)) + 1
return r

... doesn't do meta-dice though :)

```