I have a text I want to search for all it's upper case letters, then present these letters unique and sorted. I welcome any suggestions.
sneekula 969 Nearly a Posting Maven
Recommended Answers
Jump to PostYou can use Python's regular expression module re, very powerful for text processing, but there is a somewhat steep learning curve ahead!
# exploring Python's regular expression module re import re # find all upper case letters in a text: text = "This text has Upper and …
Jump to PostMy humble contribution using a list comprehension:
# create a unique sorted list of all upper case letters in text text = "This text has Upper and Lower Case Letters" unique_list = [] [unique_list.append(c) for c in text if c.isupper() and c not in unique_list] print sorted(unique_list) …
Jump to PostSo set() removes duplicates?
Yes, going fom a list to a set then back to a list removes duplicates from the list, but it will change the order of the elements. So, only use this little trick when order does not matter.
All 9 Replies

Mouche
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
jrcagle 77 Practically a Master Poster
sneekula 969 Nearly a Posting Maven
Ene Uran 638 Posting Virtuoso

Mouche
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
sneekula 969 Nearly a Posting Maven
twekberg 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.