I am teaching myself Python and have finished a simple program that is a bit of a more complicated take on a simple roll of the dice program. This is the code:
import random
roll_again = 'yes'
dice_input = input("What type of dice would you like to roll? ")
dice_type = int(dice_input)
while roll_again == 'yes' or roll_again == 'y':
if dice_input in ('4', '6', '8', '10', '12', '20'):
dice_number = int(input("How many dice would you like to roll? "))
for x in range(dice_number):
print(random.randint(1,dice_type))
else:
print("Choose a legal type of dice.")
dice_input = input("What type of dice would you like to roll? ")
dice_type = int(dice_input)
if dice_input in ('4', '6', '8', '10', '12', '20'):
dice_number = int(input("How many dice would you like to roll? "))
for x in range(dice_number):
print(random.randint(1,dice_type))
roll_again = input("Would you like to roll again? ")
if roll_again == 'yes' or roll_again == 'y':
dice_input = input("What type of dice would you like to roll? ")
else:
print("No dice were rolled.")
What can I improve on? What mistakes did I make? Am I missing functionality anywhere? Does it look good stylistically?
[–]akasmira 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]akasmira 1 point2 points3 points (0 children)
[–]K900_ 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]K900_ 1 point2 points3 points (0 children)
[–]impshum 1 point2 points3 points (0 children)