Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I've started writing this code for a lottery generator. Here is what the question asks for: Can you help me modify my code to make
I've started writing this code for a lottery generator. Here is what the question asks for:
Can you help me modify my code to make this work? I feel like I'm on the right path. Appears to be something wrong with my line: lotteryNum.append(random.randint(M))
import random
def lotteryPick(M): if M=5:
lotteryNum=[]
for i in (range (1,M+1),5): lotteryNum.append(random.randint(M)) return lotteryNum print ('The Lucky Numbers are:').format(lotteryPick())
Lottery games award players for money if they are able to match two, three four or five integers from integers selected at random in a range 1 to M (inclusive of M). Simulate a lottery game by designing a well-documented Python function, lotteryPick(M) that accepts an integer greater than five and returns a list of randomly selected integers. You will need to use Python's random module. Also, consider using the sample function embedded in the random module. Your call to sample should be of the form sample(range(1, M+1),5). In addition, your function should NOT return a value when the user selects an M less than 5. Under this condition have your function return an empty listStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started