I am new too python and had some basic programs earlier work flawlessly. However this simple lottery generator is failing too compile. I have little errors with indentation that I fixed but it still fails to run. Below is my code for this project. I am having trouble seeing where or why this will not run correctly.
import random
def main():
print('**** Welcome to the Pick-3, Pick-4 lottery number generator *********')
print('Select from the following menu:')
displayMenu()
menu=int(input())
while(menu==1 or menu==2):
displaySelection(menu)
print(lotteryNumber(menu))
displayMenu()
menu=int(input())
displaySelection(menu)
print('Thanks for trying the Lottery Application.')
print('*********************************************************')
def displayMenu():
print('Select from the following menu:')
print('1. Generate 3-Digit Lottery number')
print('2. Generate 4-Digit Lottery number')
print('3. Exit the Application')
return
def displaySelection(selected):
if (selected ==1):
print('You selected 1. The following 3-digit lottery number was generated:')
elif(selected==2):
print('You selected 2. The following 4-digit lottery number was generated:')
else:
print('You selected 3.')
return
def lotteryNumber(menu):
ran=''
digits=3 if menu==1 else 4
while digits>0:
ran=ran+str(random.randint(0,9))
digits=digits-1
return ran
if __name__ =='__main__':
main()
Aucun commentaire:
Enregistrer un commentaire