0

I am trying to make a function that takes a copied list in Japanese and only returns the unique words, separated by new lines in Google Docs. The image below is my work so far. I do not know why when I paste my copied Google Docs list, it only returns the first value. Any thoughts?

print('Paste your list: ')

j_list = input().split()

def thinner(japaneselist):

    unique_japanese = []

    for x in japaneselist:
        if x not in unique_japanese:
            unique_japanese.append(x)
    for x in unique_japanese:
        print(x)
    print(len(unique_japanese))

print(j_list)

When I try copying and pasting this:

かれ

It just returns: ['私']

Here is my image from PyCharm

petezurich
  • 9,280
  • 9
  • 43
  • 57
Steak
  • 514
  • 3
  • 15
  • `input` reacts the same way to pasting as it would if you had typed that data in yourself. If you type 私 and then Enter, the `input` call will complete, and return "私". It won't wait for the rest of your input. If you need to enter multiple lines of data, you need multiple input calls. – Kevin Feb 21 '20 at 15:00
  • If you want unrepeated values, you can use a `set` instead of a `list` – Tarifazo Feb 21 '20 at 15:03
  • As far as my understanding goes, you should enter all the words in a single line separated by spaces."input.split(' ') will take those words and convert them in a list... – Aayman Khalid Feb 21 '20 at 15:10
  • And also where are you calling the function? – Aayman Khalid Feb 21 '20 at 15:10

0 Answers0