题解 | #找出字符串中第一个只出现一次的字符#
找出字符串中第一个只出现一次的字符
http://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
while True:
try:
myStr=list(input())
mySet = set(myStr) # 字符串元素种类
dic={}
for e in mySet:
dic[e]=0
for e in mySet:
for i in range(len(myStr)):
if e==myStr[i]:
dic[e]+=1
for j in range(len(myStr)):
if j<=len(myStr)-1 and dic[myStr[j]]==1:
print(myStr[j])
break
elif j==len(myStr)-1:
print('-1')
except:
break