#import random module, to generate random numbers
# A program in which the main function creates a
#list containing 7 randomly generatednumbers
#check function will check user
#entered number is between 0to9 or not
#To create the list of random numbers first
#create an empty list
#You should set up your loop to run 7 times.
# then use a loop with the append method to add
#randomly generated values to the list.
#To create the list from the user first create
#an empty list
#then use a loop toprompt the user to enter a number
# the user should be prompted to enter 7 numbers between
# 0 and 9
# call a function to check that number
#then append the number to the list
#This should be another list
#Displaying random numbers list and user entered list
#counting mathed numbers use a loop to compare the
#numbers one at a time and count how many are the same
#The main function should output both lists and how much
#was won
#When all 7 are the same, then the user wins $500
#When all 6 are the same, then the user wins $250
#When all 5 are the same, then the user wins $120
#When all 4 are the same, then the user wins $50
#When less than 4 numbers are the same, the user does not
#win anything
import random
def check(value):
if ((value >= 0) and (value <= 9)):
return 1
else:
return 0
__init__ = “main”
randList = []
for i in range(7):
r = random.randint(0,9)
randList.append(r)
userList = []
i = 0
while i<7:
r = input(“Enter a number: “)
if(check(r)):
userList.append(r)
i = i + 1
else:
print “Invalid entry…Try again”
print “nRandom list:n”,randList
print “User Entered list:n”,userList
count = 0
for i in range(7):
if randList[i] == userList[i]:
count = count + 1
if count == 7:
print “User won $500”
elif count == 6:
print “User won $250”
elif count == 5:
print “User won $125”
elif count == 4:
print “User won $50”
else:
print “User not won anything”