-1

Here's the check50 terminal message:

:) Little Professor rejects level of 0
:) Little Professor rejects level of 4
:) Little Professor rejects level of "one"
:) Little Professor accepts valid level
:( At Level 1, Little Professor generates addition problems using 0–9
    Did not find "6 + 6 =" in "Level: 0 + 4 =..."
:( At Level 2, Little Professor generates addition problems using 10–99
    Did not find "59 + 63 =" in "Level: 15 + 43..."
:( At Level 3, Little Professor generates addition problems using 100–999
    Did not find "964 + 494 =" in "Level: 876 + 5..."
:| Little Professor generates 10 problems before exiting
    can't check until a frown turns upside down
:| Little Professor displays number of problems correct
    can't check until a frown turns upside down
:| Little Professor displays EEE when answer is incorrect
    can't check until a frown turns upside down
:| Little Professor shows solution after 3 incorrect attempts
    can't check until a frown turns upside down
.
.
.

So...

I really don't know what it's trying to check so I can make the due changes.

Here's my code for evaluation:

import random

def main():
    score = 0
    level = get_level()
    generate_integer(level)
    for i in range(10):
        chances = 3
        x,y = generate_integer(level)
        z = int(x + y)
        while True:
            try:
                answer = int(input(f"{x} + {y} = "))
                if answer == (z):
                    score += 1
                    chances = 3
                    break
                else:
                    raise ValueError
            except (ValueError, NameError):
                print("EEE")
                chances = chances - 1
            if chances == 0:
                print((f"{x} + {y} = {z}"))
                chances = 3
                break
    print(f"Score: {score}")


def get_level():
    while True:
        try:
            lvl = int(input("Level: "))
            if  0 < lvl < 4 :
                return lvl
            elif lvl < 0:
                pass
            elif lvl > 3 :
                pass
        except (ValueError,TypeError):
            pass

def generate_integer(level):
    if level == 1:
        x = random.randrange(9)
        y = random.randrange(9)
    if level == 2:
        x = random.randrange(10,99)
        y = random.randrange(10,99)
    if level == 3:
        x = random.randrange(100,999)
        y = random.randrange(100,999)
    return x,y


if __name__ == "__main__":
    main()
1
  • Not passing check50 is not a question. please try ask a specific question and figure out what is not working.
    – UpAndAdam
    Commented May 10 at 19:46

2 Answers 2

0

From the doc:

The positional argument pattern matches the range() function.

Pay close attention to the stop argument of range.

NB. The "extra" generate_integer at line 7 interferes with check50.

2
  • Hey man, I replaced the range() function, but still does not work. Commented May 8 at 18:51
  • But did you change the stop argument. the range is not inclusive of that. Commented May 8 at 21:30
0

Another likely problem. generate_integer is wrong. It should generate a single integer. If you want to call it twice for two integers call it twice.

Unclear why you have to cast z's incoming value to int, you specified in your generate_integer function that both x and y would be returning ints, but I suppose this isn't harmful.

What happens in generate_integer if they call it with a value other than on of 1,2,3? Best practice is to protect against that in generate_integer. Although this is not your bug.

You randomly call generate_integer early in main (line 7) without capturing the result... why? that could interfere potentially... since I'm guessing they seed the random number generator so they know what you will generate.

If this answers your question, please click on the check mark to accept it. Please consider upvoting the answer as well if it was useful. This helps with site maintenance.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .