有人知道如何将其转换为while循环吗?
def function(number):
dictionary_num = {}
for i in number:
if i in dictionary_num:
dictionary_num[i] += 1
else:
dictionary_num[i] = 1
答案 0 :(得分:1)
技术答案:
def whloop(numbers):
d = {}
numbers = list(numbers)
while numbers:
i = numbers.pop()
if i in d:
d[i] += 1
else:
d[i] = 1
return d
但这样做真的没有意义......