Python Forum
My first try with python
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My first try with python
#1
So, I wanted to play D&D with my friends and I had an idea. What if I code a program to roll the dice for me?
Here is my first try, I don't know anything about coding, so it kind of sucks.
Any advice is welcome.
Thank you all :3

import random
def Random():
	while True:
		try:
			dice = int(input("How many dice? "))
			break
		except:
			print("That's not a valid option!")
	while True:
		try:
			side = int(input("How many sides? "))
			break
		except:
			print("That's not a valid option!")
	x = 0
	total = 0
	while x < dice:
		x = x+1
		rolls = random.randint (1, side)
		total = total+rolls
		print rolls
	print "Total =", total
	Random()
Random()
Reply


Messages In This Thread
My first try with python - by MaxAim - Aug-06-2017, 11:15 PM
RE: My first try with python - by wavic - Aug-07-2017, 01:01 AM
RE: My first try with python - by micseydel - Aug-07-2017, 03:47 PM
RE: My first try with python - by MaxAim - Aug-07-2017, 08:32 PM
RE: My first try with python - by nilamo - Aug-07-2017, 09:01 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020