**elif int(b[0])== int(a[0]) or int(b[0])==int(a[1]) or int(b[1])==int(a[0]) or int(b[1])== int[1]:**

print ("You have won 1000 dollars")

else:

print ('Try again')

The program is supposed to determine 2 random numbers and put them together to create the lottery number. These 2 numbers should not be the same and the program should generate another 2 numbers to make a new lottery number, if these 2 numbers are the same. The program should not print the random numbers as this is the lottery winning number.

This is how the reward system would work if the lottery number was 53. If the person guesses the correct numbers in order (ie 53) the persons should win $10000 , if the person guesses the correct numbers in reverse order (ie 35) they should win $3000, and if they guess one of the numbers correctly (ie. 37 or 63 or 59 or 45), they should win $1000. Otherwise the program should print out (Try Again).

I basically want to know what how to fix my program (when the input is anything other then the input which wins them $10,000 the program fails because their is something wrong with the bolded line. I also want to know how to generate another lottery winning numbers if the 2 numbers randint generates is the same and I also want to know how to check the input to see if the input contains one of the lottery numbers.

网友答案:

There are a number of things that could be improved, but a few definite problems include:

In your long condition

int(b[1])== int[1]

should be

int(b[1])== int(a[1])

the condition for winning 3000 dollars should come before
the condition for winning 1000 dollars. Since the condition for
winning 1000 dollars is also True when the person is eligible for
winning 3000 dollars.

the condition for winning 3000 dollars should be

int(b[1])==int(a[0]) and int(b[0])==int(a[1])

(notice the change in the last index), rather than

int(b[1])==int(a[0]) and int(b[0])==int(a[0])

since you are really treating the response as strings rather than
as ints, you might as well keep a and b as strings. Doing so means you can remove all the calls to int.