-1

I want to print all the characters in a string as a list but for each character to be printed once even if recurring. So far I have:

symbolsx = []
for line in ''.join(word_lines):
   for i in line:
       symbolsx.append(i)

This prints every character, even if the character is repeated.

Dair
  • 15,910
  • 9
  • 62
  • 107
thomasdowell
  • 59
  • 1
  • 2
  • 6

2 Answers2

1

symbolsx = list(set(symbolsx))

First pass the list to set function to remove duplicates, then reverted that set back to list by passing it to list function.

Reloader
  • 742
  • 11
  • 22
0

How about:

symbolsx = []
for line in ''.join(word_lines):
    for i in line:
        if i not in symbolsx:
            symbolsx.append(i)
Tripp Kinetics
  • 5,178
  • 2
  • 23
  • 37