查找只出现一次的字符和位置

s = 'hellobaby'
def findchar(s):
    for i in s:
        if s.count(i)==1:
            return i, s.index(i)
m,n=findchar(s)
print('第一个出现一次的字符是{},位置是{}'.format(m,n))

 

posted @ 2018-01-10 15:30  553490191  阅读(162)  评论(0)    收藏  举报