79696887

Date: 2025-07-10 10:24:08
Score: 3
Natty:
Report link

It does not work, please can someone help.

import random

num = []
attempts = 0

def makeNum():
    for i in range(4):
        x = random.randrange(0, 9)
        num.append(x)
    if len(num) > len(set(num)):
        num.clear()
        makeNum()

def playGame():
    global attempts
    attempts = attempts + 1
    
    cows = 0
    bulls = 0

    print(num)
    try:
        choice = int(input("Please enter a 4 digit number: "))
        guess = []

    except ValueError:
        print("invalid input try again, enter only digits.")
        playGame()
    
    for i in range (4):
        guess.append(int(choice[i]))
    for i in range (4):
        for j in range(4):
            if(guess[i] == num[j]):
                cows = cows + 1
                
    for x in range (4):
        if guess[x] == num[x]:
            bulls = bulls + 1
            
    print("Bulls: ", bulls)
    print("Cows: ", cows)
    
    if(bulls == 4):
        print("You won after " ,attempts, "attempts.")
    if(bulls != 4):
        playGame()

makeNum()
playGame()
print("You won the game.")
Reasons:
  • RegEx Blacklisted phrase (3): can someone help
  • Long answer (-1):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Brian