0

Help! Deja Vu Challenge using Python 3. Edit the code below please!

user_input = input(": ") if user_input==str: c=[] for i in len((user_input) -1): user_input[i]+=c for y in len((c)-1): if c[y]==y+1: print("Deja Vu") else: print("Unique")

31st Jan 2020, 12:35 AM
Hzkel
Hzkel - avatar
8 Respuestas
+ 3
For python: myList = list(input()) if any ([myList.count(i) > 1 for i in myList]): print("Deja Vu") elif all ([myList.count(i) == 1 for i in myList]): print("Unique")
29th Dec 2020, 9:41 PM
Adam Mahmood
Adam Mahmood - avatar
+ 2
scrap it all and start again... Think about sets...what happens when you put a string in a set?
31st Jan 2020, 1:05 AM
rodwynnejones
rodwynnejones - avatar
+ 1
Alexandr, What is PEP 8? and why doesn't it return anything? Why only ": "? How is it going to take input the code?
31st Jan 2020, 4:28 AM
Hzkel
Hzkel - avatar
+ 1
rodwynnejones, is there any way except sets? Because i haven't reached that level! I am on try and exceptions
31st Jan 2020, 4:31 AM
Hzkel
Hzkel - avatar
+ 1
myList = list(input()) count = 0 for x in myList: n = myList.count(x) if n > 1: print("Deja Vu") count = 0 exit() else: count += 1 if count > 0: print("Unique")
15th May 2020, 1:45 PM
Michael King
Michael King - avatar
0
Loop through the string and use the string count() method.
31st Jan 2020, 9:35 AM
rodwynnejones
rodwynnejones - avatar
0
print((lambda i:'Unique' if sorted(i)==sorted(set(i)) else 'Deja Vu')(input()))
11th Jun 2021, 11:08 AM
Naveen Surya
Naveen Surya - avatar
0
# Take input as a string and store it in a list type = list(input()) # Initialize an empty set variable e to store unique characters e = {""} # Iterate over each character in the input for i in type: # Add the character to the set e e.add(i) # Check if the length of the set e minus 1 is equal to the length of the input # If it is, all characters are unique, so print "Unique" # Otherwise, there are duplicate characters, so print "Deja Vu" print('Unique') if len(e)-1 == len(type) else print("Deja Vu")
3rd Sep 2023, 11:52 AM
1 2
1 2 - avatar