Skip to content
Advertisement

Implementing a match counter into a lotto number guesser

im rather new to python and found someones lottery simulation in github. After playing around with it for a while i wanted to add a counter, that counts the number of matches of your Number out of the total draws.

I don’t know if it is because i did not write the code myself, but i can’t seem to make it happen. I’ve tried some of pythons counter modules bu that did’nt seem to be the right thing.

Heres my code:

JavaScript

If anyone knows a way to implement a counter, that counts the number of times this the program gets 3,4,5 or 6 correct matches i would be super relieved! It’s not that this project would be super important but solving the problem would be a milestone for me and my learning process!

Thanks in advance and best wishes!

Advertisement

Answer

How about this where I have added a check of the numbersMatched value and increment a counter whenever it is 3 or more

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement