python 找出字符串中第一个只出现一次的字符
找出字符串中第一个只出现一次的字符(题面已经更新)
http://www.nowcoder.com/questionTerminal/e896d0f82f1246a3aa7b232ce38029d4
while True:
try:
in_str = input()
res = []
flag = False
for x in in_str:
if in_str.count(x) == 1:
res.append(x)
flag = True
if flag == False:
print(-1)
else:
print(res[0])
except:
pass
while True:
try:
s = input()
a = []
for i in s:
if s.count(i) == 1:
a.append(i)
if len(a) == 0:
print(-1)
else:
print(a[0])
except:
break