用Python编写一个程序利用集合分析活动投票情况。第一小队有五名队员,序号是1,2,3,4,5;第二小队也有五名队员,序号6,7,8,9,10。输入一个得票字符串,求第二小队没有得票的队员 输入格式: 在一行中输入得票的队员的序列号,用逗号隔开。 输出格式: 一行中输出第二小队没有得票的队员序号。
时间: 2023-07-31 14:14:06 浏览: 49
以下是一个实现该功能的 Python 代码:
```python
# 定义两个小队的队员序号集合
team1 = {1, 2, 3, 4, 5}
team2 = {6, 7, 8, 9, 10}
# 读入投票结果字符串,转换为队员序号集合
votes = input().split(',')
votes_set = set(map(int, votes))
# 计算第二小队没有得票的队员序号
no_votes = team2 - votes_set
# 输出结果
print(','.join(map(str, sorted(no_votes))))
```
例如,如果输入字符串为 "6,7,9,10",则输出结果为 "8"。