Lottery program in python from Y Daniel Liang : <p>I am new to python. The following is a practice programming exercise from Y Daniel Liang Python book Chapter 4.
if the lottery number is 333, am getting perfect match for different user inputs such as 133, 233, 433, 533, 633, 733, 833, 933, I have no idea why.</p>

<pre><code>#!/usr/bin/env python3

#import random

lottery = 333  #random.randint(100, 999)
guess = int(input("\nEnter a three-digit number: "))
print("\nThe Lottery Number is:", lottery)

lottery_digit1 = lottery // 100
lottery %= 100
lottery_digit2 = lottery // 10
lottery_digit3 = lottery % 10

guess_digit1 = guess // 100
guess %= 100
guess_digit2 = guess // 10
guess_digit3 = guess % 10

if guess == lottery:
    print("Perfect Match: First Prize $10,000")
elif (guess_digit1 == lottery_digit1 or
      guess_digit1 == lottery_digit2 or
      guess_digit1 == lottery_digit3) and \
    (guess_digit2 == lottery_digit1 or
     guess_digit2 == lottery_digit2 or
     guess_digit2 == lottery_digit3) and \
    (guess_digit3 == lottery_digit1 or
     guess_digit3 == lottery_digit2 or
     guess_digit3 == lottery_digit3):
    print("Matching All Digits: Second Prize $3,000")
elif (guess_digit1 == lottery_digit1 or
      guess_digit1 == lottery_digit2 or
      guess_digit1 == lottery_digit3) or \
    (guess_digit2 == lottery_digit1 or
     guess_digit2 == lottery_digit2 or
     guess_digit2 == lottery_digit3) or \
    (guess_digit3 == lottery_digit1 or
     guess_digit3 == lottery_digit2 or
     guess_digit3 == lottery_digit3):
    print("Matching a Single Digit: Third Prize $1,000")
else:
    print("Nice Try.")
</code></pre>
