Answer the question
In order to leave comments, you need to log in
How to output once each character in a string?
this code example displays only those characters that occur once in a string
my_str = "aaaaaaaaaaaaaaaaaaaaaannnnaaaaaaaaaaaahaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaa"
for letter in my_str:
if my_str.count(letter) == 1:
print(letter)
Answer the question
In order to leave comments, you need to log in
In [28]: s = "abac"
In [29]: for e in set(s):
...: print(e)
...:
a
c
b
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question