在国际象棋游戏中,您经常可以估计自己的状态(保持中)

问题描述 投票:-3回答:1

l = [“ a”,“ b”,“ b”][[x(l.count(x)] for set(l)中的x]]

python python-3.x
1个回答
0
投票
尝试一下:(不使用任何循环和if-else条件语句)

d = {'P' : 1, 'B' : 3, 'K' : 3, 'R' : 5, 'Q' : 9} def chess_score(string): return sum(map(lambda x : d[x], string)) print(chess_score('BQBP')) # Output : 16

© www.soinside.com 2019 - 2024. All rights reserved.