Turn Booleans into Words
In a user interface, people usually see clear words instead of raw boolean values. Write bools_to_words, which takes a list arr and replaces each True with the string Yes and each False with the string No. The order of the elements must stay the same.
Примеры
Ввод
[True, False]Вывод
["Yes", "No"]Ввод
[]Вывод
[]Ввод
[True, True, True]Вывод
["Yes", "Yes", "Yes"]Нужно реализовать
def bools_to_words(arr: list) -> list[str]:
Теги
listsarraystrings
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięVisible tests
1
Input
[true,false]Expected
["Yes","No"]2
Input
[]Expected
[]3
Input
[true,true,true]Expected
["Yes","Yes","Yes"]4
Input
[false,false]Expected
["No","No"]5
Input
[false,true,false,true]Expected
["No","Yes","No","Yes"]6
Input
[true]Expected
["Yes"]Focus radio
Paused · SomaFM · Fluid