Oct-14-2017, 01:36 AM
For my homework, I need to make a lottery number generator, a program that generates a 7 digit lottery number, each digit generated on their own and between 0-9, then puts them in a list. By looking through my textbook and assignments done in class, I was able to piece this together:
def main():
lottery_list = []
import random
random.seed(10)
random1 = random.randint(0, 9)
lottery_list.append(random1)
random2 = random.randint(0, 9)
lottery_list.append(random2)
random3 = random.randint(0, 9)
lottery_list.append(random3)
random4 = random.randint(0, 9)
lottery_list.append(random4)
random5 = random.randint(0, 9)
lottery_list.append(random5)
random6 = random.randint(0, 9)
lottery_list.append(random6)
random7 = random.randint(0, 9)
lottery_list.append(random7)
main()
print lottery_listbut I keep getting this error:Error:Traceback (most recent call last):
File "C:/Users/Sami3_000/Documents/School/Intro to Program Logic and Design/Ch7Ex2.py", line 28, in <module>
print lottery_list
NameError: name 'lottery_list' is not definedWhy does it think I haven't defined it? And how can I improve my program?
