Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7446725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:23:38+00:00 2026-05-29T12:23:38+00:00

I’m writing a program that simulates a lottery game, and I’m stuck at a

  • 0

I’m writing a program that simulates a lottery game, and I’m stuck at a certain point. I’m trying to match the user’s guesses with the numbers on the winning ticket, but my function “checkmatch” apparently takes 2 arguments, but I’m only giving it 1? I know there are similar questions on the site, but I’m a very novice programmer, and the others seemed… a bit above me. This is my program in its entirety (thus far):

import random

def main():
random.seed()

#Prompts the user to enter the number of tickets they wish to play.
tickets = int(input("How many lottery tickets do you want?\n"))

#Creates the dictionaries "winning_numbers" and "guess"
winning_numbers = []
guess = []

#Generates the winning lotto numbers.
for i in range(tickets):
    del winning_numbers[:]
    del guess[:]
    a = random.randint(1,30)
    winning_numbers.append(a)

    b = random.randint(1,30)
    while not (b in winning_numbers):
        winning_numbers.append(b)


    c = random.randint(1,30)
    while not (c in winning_numbers):
        winning_numbers.append(c)


    d = random.randint(1,30)
    while not (d in winning_numbers):
        winning_numbers.append(d)

getguess(guess, tickets)
nummatches = checkmatch(guess)
nummisses = checkmiss()

    #print(winning_numbers)

#Gets the guess from the user.
def getguess(guess, tickets):
    del guess[:]

for i in range(tickets):
    bubble = input("What numbers do you want to choose for ticket #"+str(i+1)+"?\n").split(" ")
    guess.append(bubble)

#Checks the user's guesses with the winning numbers.
def checkmatch(winning_numbers, guess):
    match = 0
    for i in range(5):
        if winning_numbers[i] == guess[i]:
            match = match+1

return match

And this is the part that is giving me trouble:

def checkmatch(winning_numbers, guess):
match = 0
for i in range(5):
    if winning_numbers[i] == guess[i]:
        match = match+1

return match

And here is what I get when I try a test run:

How many lottery tickets do you want?
3
What numbers do you want to choose for ticket #1?
1 2 3 4 5
What numbers do you want to choose for ticket #2?
1 2 3 4 5
What numbers do you want to choose for ticket #3?
1 2 3 4 5 
Traceback (most recent call last):
  File "C:/Users/Ryan/Downloads/Program # 2/Program # 2/lottery.py", line 64, in    <module>
    main()
   File "C:/Users/Ryan/Downloads/Program # 2/Program # 2/lottery.py", line 36, in main
    checkmatch(guess)
TypeError: checkmatch() takes exactly 2 arguments (1 given)

Thank you for any and all help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:23:39+00:00Added an answer on May 29, 2026 at 12:23 pm

    The problem is

    nummatches = checkmatch(guess)
    

    In your code checkmatch takes 2 arguments winning_numbers & guess but when you are calling it you are only giving a single argument.

    Like for example

    >>> def myfunc(str1,str2):
    ...   print str1+str2
    ...
    >>> myfunc('a','b') #takes 2 argument and concatenates
    ab
    >>> myfunc('a') # only one given so ERROR
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: myfunc() takes exactly 2 arguments (1 given)
    >>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.