Ones and Fours Balance
Sometimes you need to compare how many times two different values appear in a list. Write a function more_14 that takes a list nums and counts the number of 1 values and 4 values. Return True if the counts are equal, otherwise return False.
Примеры
Ввод
[1, 4, 1, 4]Вывод
TrueВвод
[1, 1, 4]Вывод
FalseВвод
[1, 4, 1]Вывод
FalseНужно реализовать
def more_14(nums: list[int]) -> bool:
Теги
listsarray
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,4,1,4]Expected
True2
Input
[1,1,4]Expected
False3
Input
[1,4,1]Expected
False4
Input
[]Expected
True5
Input
[4,4,1,1]Expected
True6
Input
[2,5,2,5]Expected
TrueFocus radio
Paused · SomaFM · Fluid