dimanche 17 septembre 2023

2 number command line lottery returning a win every time [duplicate]

I'm creating a code that accepts two numbers as command line arguments. these numbers are then compared against two randomly generated integers and inform the user if they have matched the numbers that were generated. while I succeeded in the printing of the numbers and my programs runs, it returns to the user that they have always matched one of the numbers regardless of if they did or did not.

my current code is:

    import sys
    import random 
    Pick1 = int(sys.argv[1])
    Pick2 = int(sys.argv[2])
    Lot1 = random.randint(1, 10)
    Lot2 = random.randint(1, 10)
    print("The lottery numbers were " + str(Lot1) + " and " + str(Lot2) + ".")
    print("Your picks were " + str(Pick1) + " and " + str(Pick2) + ".")
    if (Pick1 == Lot1 or Lot2):
        print("You matched one number! You win $100!!")
    elif (Pick1 == Lot1 or Lot2) and (Pick2 == Lot1 or Lot2):
        print("You matched both numbers! Congratulations! You win $1000!!")
    else:
        print("Sorry, no match.")
 

i have tried adjusting the conditionals but no matter what i do it returns that they have always matched one of the lottery numbers.




Aucun commentaire:

Enregistrer un commentaire