我在一次演习中告诉我说,每个人都有偏好的数字。 当我来到人数不止一个的人时,我不能把人数放在一条线上,按 com子分开。 你们能否提出解决办法?
我的法典
favourite_numbers = {
"ha": [20, 10, 4],
"quynh": [2, 5],
"nhung": [3, 10, 12],
"giang": [10],
}
for name, numbers in favourite_numbers.items():
if len(numbers) == 1:
for number in numbers:
print(f"
{name.title()} s favourite number is {number}.")
elif len(numbers) >= 2:
print(f"
{name.title()} s favourite numbers are:")
for number in numbers:
print(f"{number}")
人数众多的人的产出就好像这样。
Ha s favourite numbers are:
20
10
4
我期望这样做:
Ha s favourite numbers are: 20, 10, 4