import random, sys

# Let the user enter their guess:
print('I will roll two dice. Guess if the sum is even or odd:')
guess = input('>')

# Do input validation:
if guess != 'even' and guess != 'odd':
    print('You must enter "even" or "odd"')
    sys.exit()

# Get two random numbers for the dice rolls:
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
total = die1 + die2
total_is_even = total % 2 == 0

# Display the results:
print('The dice were', die1, 'and', die2, 'for a total of', total)
if total_is_even:
    if guess == 'even':
        print('The total was even. You win!')
    else:
        print('The total was even. You lost.')
else:
    if guess == 'even':
        print('The total was odd. You lost.')
    else:
        print('The total was odd. You win!')