Jump to content

Using two input text files and the latest prize data from powerball com, I threw together a scrip...


G+_Brandon Ingli
 Share

Recommended Posts

Using two input text files and the latest prize data from powerball.com, I threw together a script to check powerball tickets!

 

Just put the three files in the same directory and it works fine

Proper formats of the files are in the comments of the script.

 

Enjoy and love the show!

 

 

UPDATE: Updated code to use for loops and lists over repetitive variables! Thanks commenters!

https://github.com/mrbmi513/c101/tree/master/powerball%20checker

Link to comment
Share on other sites

It does that too. I knew there has to be a way to do it. I saw some things like maps and lamdas and zips that maybe others can comment on. But I finally found the nested comprehension syntax at Stack Overflow and it works like a charm. It's the line that says:

 

your_tickets = [[int(num) for num in ticket.split(",") if num.isdigit()] for ticket in initial_your_numbers.split(

';')]

 

I still have to get my head around it to read it. The format for a single list is:

[item1/function on item1 for item1 in list1 if condition]

It's a way to mash three or four lines of code into one and let's you substitute ... so that your item1/function could a nested list comprehension like in the case of the tickets!

 

Now I see why Python is so popular.

Link to comment
Share on other sites

Yeah, lots of repetition. Anytime you start to use variables like win1, win2, win3, you should immediately start thinking of coverting to a list (or dictionary or set). Not only will it make the code simpler and more efficient, but also easier to change and adapt to different sizes.?

Link to comment
Share on other sites

 Share

×
×
  • Create New...