题解 | #找出字符串中第一个只出现一次的字符#
找出字符串中第一个只出现一次的字符
https://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
s = input()
result = 0
a = [i for i in s]
b = []
for i in s:
if i not in b:
b.append(i)
for i in b:
if a.count(i) == 1:
result = i
break
else:
continue
if result:
print(result)
else:
print(-1)
😄
result = 0
a = [i for i in s]
b = []
for i in s:
if i not in b:
b.append(i)
for i in b:
if a.count(i) == 1:
result = i
break
else:
continue
if result:
print(result)
else:
print(-1)
😄