题解 | #找出字符串中第一个只出现一次的字符#
找出字符串中第一个只出现一次的字符
https://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
str1 = input() res = '-1' # 初始化为-1 for i in str1: if str1.count(i) == 1: # 按顺序遍历,找到第一个个数等于1的 res = i break print(res)
找出字符串中第一个只出现一次的字符
https://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
str1 = input() res = '-1' # 初始化为-1 for i in str1: if str1.count(i) == 1: # 按顺序遍历,找到第一个个数等于1的 res = i break print(res)
相关推荐