No shorter, but may be debugged:
if guess4== code[0]:
wronPlace= (wronPlace+1)
if guess3== code[1]:
wronPlace= (wronPlace+1)
if guess3== code[2]:
wronPlace= (wronPlace+1)
Are you sure about the
guess3
in this part?
[Update]
Quote:
Guess1 Guess2 Guess3 and Guess4 are the four digits I split apart from guess. They need to be compared to the four generated digits
Read carefully your code!
you check
guess1
3 times,
then you check
guess2
3 times,
then you check
guess3
3 times,
at this point, one can expect you to check
guess4
3 times but,
you check
guess4
1 time and
guess3
2 times.
Is it what you want?
[Update]
Quote:
Codebreaker: It is a game where you guess 4 digits of a code. It outputs the amount of correct digits in the correct place and amount of correct digits in the WRONG place. The code is stored as a array. You have 12 guesses to guess the code
OK. So your code is plain wrong because you don't handle when there is 2 identical digits in code or guesses.
Example: code is 1123 and guess is 3211, your program will say there is 6 wrong placed digits.
You have to rethink the logic.