import random #Number of moons x = 0 dice = [] #Make dice #If there is a two, three, or a five, add 1, 2, or 4 to x. for z in range(1, 6): z == random.randrange(1, 7) dice.append(z) if z == 3: x += 2 if z == 5: x += 4 #print dice numbers and number of moons print dice print "There are %s moons around the planets" % x
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question