0

Hi Everyone,

Sorry if this has a totally obvious solution. I am trying to write a simple cows and bulls game; the program generates a secret number, the player has to guess it, the program then compares the guess to the secret number and tells the player that either they have guessed it, or they have gotten x number of cows (right number in right position) and x number of bulls (right number in wrong position).

I've had a go but I have been working on this for long it's all jumbled up. It just doesn't work as it is below. Can anyone help?

```
import random
secret_number = random.randrange(100) + 1
# Secret number printed here just for testing purposes
print secret_number
guess = int(raw_input("Guess a number between 1 and 100: "))
tries = 1
if guess == secret_number:
print "\nYou guessed it! The number was", secret_number
else:
while count != len(secret_number_str):
if guess[len(secret_number_str) - (len(secret_number_str) - count)]== secret_number_str[len(secret_number_str) - (len(secret_number_str) - count)]:
cows += 1
elif guess[len(secret_number_str) - (len(secret_number_str) - count)] in secret_number_str:
bulls += 1
tries+= 1
print "\nYou guess has", cows, "cows and", bulls, "bulls \n"
raw_input("\n\nPress the enter key to exit.")
```