+ 1
Phython code
Hi can someone help me write a function for this topic Write a python function that takes a sequence of numbers and determines if all the numbers are different from each other
9 Answers
+ 1
Did you start writing some code?
+ 1
For each element in the sequence, drop the element and see if there is another element with the same value in the remaining sequence.
You may use the slicing syntax to drop the element and get the remaining sequence.
+ 1
whats phython??????
0
no, i dont understand how to
0
ok thank you
0
A quickly written example:
seq = [12, "a", 25, 72, "v", 12]
rem = seq
dup = 0
for el in seq:
rem = rem[1::]
if el in rem:
print ("There is a duplicate in the sequence")
dup = 1
break
if dup == 0:
print("There is no duplicate in the sequence")
0
https://code.sololearn.com/cjg8INOR5TZ2/?ref=app
0
Shorter:
if len (set(seq)) == len (seq):
print ("no duplicate")