Python如何输出重复次数

前两行为给定输入:
第一行为输入字符串
第二行为重复次数

拜托大神~

s = input()
n = int(input())
print("字符串是" + s)
print("重复次数" + str(n))

str=input('请输入字符串:')
i=0
cf=[]   #记录重复的数据
time=[] #记录重复的次数
while i<len(str):
    if str.count(str[i])>1:
        if str[i] in cf:
            i+=1
            continue
        cf.append(str[i])
        time.append(str.count(str[i]))
    i+=1
print('重复的元素有:%s'%cf)
print('对应重复次数:%s'%time)

s = 'abca'
dict1 = {i:s.count(i) for i in set(list(s))}
print(dict1)

输出:{'b': 1, 'a': 2, 'c': 1}