I’m trying to make a lottery system in Python using the following code:
failed = True
passed = False
number_of_tickets = []
ticket_num = []
ticket_cost = int(10)
ticket_cost_sum = 0
randomly_generated_num = []
final_ticket = []
ticket_sum_inquiry = (int(input("Enter number of tickets: ")))
ticket_sum_inquiry
print (ticket_sum_inquiry)
print ("It will cost", ticket_sum_inquiry*ticket_cost, "dollars for these tickets.")
import random
def randint(min=1,max=100):
randomly_generated_num = random.randint(min,max)
return randomly_generated_num
randint()
ticket_num.append(randomly_generated_num)
Proceed = input('Would you like to continue? enter "y" for yes, enter "n" no: ' )
if Proceed.lower() == "y":
print ("Great, here are your tickets with their numbers:")
for tickets, numbers in zip(ticket_sum_inquiry, ticket_num):
print(tickets, ':', {randint(numbers)} )
elif Proceed.lower() == "n":
print ("Goodbye")
else:
As you can see, the code is incomplete, as I’ve yet to implement the winning numbers for the lottery. However, along the way, I encountered a problem when trying to give the user their **tickets **along with generating the corresponding numbers to those tickets:
for tickets, numbers in zip(ticket_sum_inquiry, ticket_num):
print(tickets, ':', {randint(numbers)} )
Whenever I try to run this, Python returns:
TypeError: ‘int’ object is not iterable
Liv.K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.