OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

I'm having issues with the error: " 'int' object not interable "error while trying to make a lottery system in Python

  • Thread starter Thread starter Liv.K
  • Start date Start date
L

Liv.K

Guest
I'm trying to make a lottery system in Python using the following code:

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:

Code:
 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
<p>I'm trying to make a lottery system in Python using the following code:</p>
<pre><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:
</code></pre>
<p>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 <strong>corresponding numbers to those tickets</strong>:</p>
<pre><code> for tickets, numbers in zip(ticket_sum_inquiry, ticket_num):
print(tickets, ':', {randint(numbers)} )
</code></pre>
<p>Whenever I try to run this, Python returns:
TypeError: 'int' object is not iterable</p>
 

Latest posts

Top