Using random.randint help in python
Question: The following code is my attempt at simulating a lottery.

    
    
    import random
    
    def lottery(numbers):
        lottoNumbers = [randint('0,100') for count in range(3)]
    
        if numbers == lottoNumbers:
            print('YOU WIN $10,000')
        else:
            print('YOU LOSE,DUN DUN DUNNN!')
        return numbers
    
    
    def main():
        numbers = int(input('Enter a number: '))
        if numbers == lottoNumbers:
            numbers = lottery(numbers)
        else:
            numbers = lottery(numbers)
    
    
    
    
    main()
    

Hey guys I've gotten this far with the help you've given me. I'm trying to
write the code so that 3 lotto numbers at random will be chosen. Then the user
must enter 3 of his/her own lotto numbers. If they get all 3 correct then they
win the whole prize, if they get the 3 numbers but not in the correct order
they win some of the prize. Obviously if they guess all wrong then a print
statement would state that. What I'm confused about is how can I write the
code so that the user can enter 3 numbers to try matching the random lottery
numbers. I also want to print the 3 lottery numbers after the user inputs
his/her choices. Any ideas guys?

Thanks for your help everyone.


Answer: There are a few things wrong with your implementation, to name a few:

if you are trying to compare the output of the function `randm` to x, you will
need to include a return value in the function, like so:

    
    
    def randm():
        return return_value
    

You appear to be printing all the values but not storing them, in the end you
will only end up with the final one, you should attempt to store them in a
list like so:

    
    
    list_name = [randint(0,100) for x in range(x)]
    

This will generate `randint(0,100)` `x` times in a list, which will allow you
to access all the values later.

To fix up your code as close to what you were attempting as possible I would
do:

    
    
    import random
    
    def randm(user_numbers):
        number = []
        for count in range(3):
            number.append(random.randint(0, 100))
        print(number)
        return user_numbers == number
    
    if randm(x):
        print('WINNER')
    

* * *

If you are looking for a very pythonic way of doing this task, you might want
to try something like this:

    
    
    from random import randint
    
    def doLotto(numbers):
        # make the lotto number list
        lottoNumbers = [randint(0,100) for x in range(len(numbers))]
    
        # check to see if the numbers were equal to the lotto numbers
        if numbers == lottoNumbers:
            print("You are WinRar!")
        else:
            print("You Lose!")
    

I'm assuming from your code (the print() specifically) that you are using
python 3.x+

