Codewars note: Convert boolean values to strings 'Yes' or 'No'

"My

>> False >> 'No'

>>True >> 'Yes'

Solutions:

1

def bool_to_word(boolean):
    return "Yes" if boolean else "No"

2

def bool_to_word(boolean):
    return ['No', 'Yes'][boolean]
def bool_to_word(boolean):
    return ['No', 'Yes'][boolean]

bool_to_word(False)


>>'No'

 

posted @ 2022-07-10 14:18  大序列  阅读(18)  评论(0编辑  收藏  举报