Phython code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

16th Jan 2019, 11:22 PM
Nisha
9 Answers
+ 1
Did you start writing some code?
16th Jan 2019, 11:33 PM
jcl
jcl - avatar
+ 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.
16th Jan 2019, 11:40 PM
jcl
jcl - avatar
+ 1
whats phython??????
7th Feb 2020, 4:48 AM
Aaron Liu
0
no, i dont understand how to
16th Jan 2019, 11:35 PM
Nisha
0
ok thank you
16th Jan 2019, 11:49 PM
Nisha
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")
16th Jan 2019, 11:53 PM
jcl
jcl - avatar
17th Jan 2019, 3:39 AM
Ahmad Ali
Ahmad Ali - avatar
0
https://code.sololearn.com/cjg8INOR5TZ2/?ref=app
17th Jan 2019, 6:30 AM
Anna
Anna - avatar
0
Shorter: if len (set(seq)) == len (seq): print ("no duplicate")
17th Jan 2019, 6:57 AM
jcl
jcl - avatar