Итак, я пытаюсь сделать эту программу, которая попросит пользователя ввести и сохранить значения в массиве/списке.
Затем, когда пустая строка будет введена, она сообщит пользователю, сколько из этих значений уникально.
Я строю это по причинам реальной жизни, а не как проблема.
enter: happy
enter: rofl
enter: happy
enter: mpg8
enter: Cpp
enter: Cpp
enter:
There are 4 unique words!
Мой код выглядит следующим образом:
# ask for input
ipta = raw_input("Word: ")
# create list
uniquewords = []
counter = 0
uniquewords.append(ipta)
a = 0 # loop thingy
# while loop to ask for input and append in list
while ipta:
ipta = raw_input("Word: ")
new_words.append(input1)
counter = counter + 1
for p in uniquewords:
.. и это обо всем, что я получил до сих пор.
Я не уверен, как подсчитать уникальное количество слов в списке?
Если кто-то может опубликовать решение, чтобы я мог учиться на нем, или, по крайней мере, показать мне, как это было бы здорово, спасибо!