PYTHON Lottery Number Generator Question Design a program th
PYTHON: Lottery Number Generator
Question: Design a program that generates a seven-digit lottery number. The program should generate seven random numbers, each in the range of 0 through 9, and assign each number to a list element. Then write another loop that displays the content of the lsit.
What I have:
import random
def main():
#Create a list
numbers=[0]*7
#populate the list with random numbers
for index in range (7):
numbers [index]=random.randint(0,0)
#Display the random numbers
print (\'Here are your lottery numbers:\')
for index in range (7):
print(numbers[index],end=\'\')
#Separate curent numbers from next number with commas.
STUCK HERE
main()
I\'m stuck after that comment about separate current number from next number with commas. I figured out a way already that works but I\'d really like to understand this method. Thank you in advance for all the help!!
Solution
#Start
def lotteryNo():
import random
integer = []
for number in range(0 , 7):
integer.append(random.randint(0, 9))
return integer
print \'The Lucky Winning Numbers Are {}\'. format(lotteryNo())
print \'\ Thank You for playing\'
#End
Please use this code.
