猜數字遊戲
def main():
answer = "test"
user_input = ""
score = 100
count = 0
while user_input!=answer:
user_input = raw_input("Enter a length 4 word start with t:")
if len(user_input)<len(answer):
print("Wrong input, input again.")
continue
response = map(lambda x: x[0]==x[1] and x[0] or '*', zip(answer,
user_input[:4]))
print(' '.join(response))
count = count + 1
print("Congratulations! The answer is {0}!".format(answer))
print("Score: {0}".format(score-(count-1)*10))
if __name__ == "__main__":
main()