1.重复元素
描述:编写一个函数,接受一个列表作为参数,返回列表中所有重复的元素。
words = input().split()
results = []
count = 0
for word in words:
if words.count(word) > 1 and word not in results and word !=' ':
results.append(word)
count += 1
for i in range (0,count):
if i != count-1:
print(results[i],end = ' ')
else :
print(results[i])
2.昙花一现
描述:实现一个函数,接受一个字符串作为参数,返回字符串中只出现一次的字符,按照出现的顺序返回。
words = input()
results = []
count = 0
for word in words:
if words.count(word) == 1 and word not in results:
results.append(word)
count += 1
for i in range (0,count):
if i != count-1:
print(results[i],end = ' ')
else :
print(results[i])
3.门禁系统
描述:涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况。
每位读者有一个唯一编号,每条记录用读者的编号来表示