Python Forum
Lottery generator (beginner)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lottery generator (beginner)
#2
First of all, you shouldn't name a list 'list'. The word 'list' is a built-in type/function in Python. If you name your list 'list', you no longer have access to the built-in. This may cause problems if you are using/importing other people's code. Call your list something like 'numbers', which describes what's in the list.

Second, you need to define the list in the function, so that it gets reset every time the function is called. As it is, you always appending to the same list. That's why your output gets longer and longer each time.

Third, moving the definition inside the function will make it unavailable outside the function. You will need to use the return statement to return it from the function, and you will need to assign the function call on line 11 to a variable. Details on how to do this are in the functions tutorial link in my signature below.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Lottery generator (beginner) - by Hullari - Jul-03-2019, 02:59 PM
RE: Lottery generator (beginner) - by ichabod801 - Jul-03-2019, 03:20 PM
RE: Lottery generator (beginner) - by Hullari - Jul-03-2019, 03:59 PM
RE: Lottery generator (beginner) - by perfringo - Jul-03-2019, 04:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with defining messages and player guesses in a lottery Kanashi 3 2,421 Nov-23-2019, 10:14 AM
Last Post: ThomasL
  [split] Lottery System on my mobile website sibt007 1 2,504 Sep-27-2018, 12:56 AM
Last Post: micseydel
  Lottery System on my mobile website nooxm123 1 2,667 Feb-06-2018, 10:55 AM
Last Post: j.crater
  receive from a generator, send to a generator Skaperen 9 5,693 Feb-05-2018, 06:26 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020