+ 1
Please help
Во входной строке записана последовательность чисел через пробел. Выведите слово yes, если это число уже встречалось в последовательности или no, если не встречалось. The input string contains a sequence of numbers separated by a space. Print the word yes if this number has already occurred in the sequence, or no if it has not. https://code.sololearn.com/c5JIWrFzMM02/?ref=app
2 Answers
+ 1
You are confusing the variables, when you create your set.
First, to diagnose what is happening at the end of your code you can print both the list and the set, then it might be obvious to see the error.
print(l)
print(numbers)
The problem is with your for loop. What you do currently is you loop through an empty set (l) so it actually does not do anything. The other problem is that you cannot add the whole list, you have to add each element separately, which is represented by the loop variable (number)
Fixed loop:
for number in numbers:
l.add(number)
+ 2
Thanks a lot 😁😁😁