this first post, , try detailed possible.
i recreating game "mastermind", instead of colors, letters used. color "red" "r", "yellow" "y", etc...
i must check errors, , when error inputted user, output should guess = input("error, try again: ")
.
any errors can not counted attempt. there total of 8 attempts. must check other things well, have completed part.
here code having trouble with:
if len(guess) == 4 , (guess.upper().count("r") + guess.upper().count("y") + guess.upper().count("b") +\ guess.upper().count("g") + guess.upper().count("w") + guess.upper().count("o") == 4):
for colors rgybwo
, if user inputs example: rygw
, can sum up == 4?
in simpler terms, can check each letter there , add them = 4 ?
if not, post full code.
use sum
built in:
uppercase_guess = guess.upper() #no need call every time. if sum(uppercase_guess.count(i) in "rgybwo") == 4: ...
although if want check every character 1 of characters might clearer do:
if ( all((i in "rgybwo") in guess.upper()) , len(guess) == 4): ...