Deja Vu code coach problem
text=input() for i in range(0,len(text)): s=text[i] count = 0 for j in range(0,len(text)): if s==text[i]: count=count+1 if count >1 : print("Deja Vu") break if i == (len(text)-1): print("Unique") I am struck in this problem plzz help!
Got my logic 👍👍thank you
I like your solution. I used this approach: First I load the input into a list next I used set to convert a copy of the list to a set. Since sets do not allow duplicates I simply compared the len of the set and list to determine if it was deja vu or not.
David Carroll I am going to look that up and try that out. Thanks for sharing that!
s = input() c = 0 for l in s: if s.count(l) > 1: c += s.count(l) c -= int(c/2) if c > 1: print('Deja Vu') else: print('Unique')
Paul K Sadler Another option could be to use the any() function on a sorted list. This can compare the current with the previous positions which will return True as soon as the first match is found. 😉
s = input() c = 0 for l in s: if s.count(l) > 1: c = s.count(l) if c > 1: print('Deja Vu') else: print('Unique')
Uh can use dictionaries also
def checker(text): r = '' for i in text: if r != i: r = i else: return 'Deja Vu' return 'Unique' t = input() print(checker(t))
Whoa. I did it a little different y'all. I'm not even sure what to say other than it worked. rndm_char = input() x = set(rndm_char) re_strng = ''.join(x) print('Unique' if len(rndm_char) == len(re_strng) else 'Deja Vu')
I think sets should be used... Set cannot have the same element
letters=input() c= for i in letters: c.append(1) if letters.count(i)>1 else c.append(0) print('Deja Vu' if sum(c)>=1 else 'Unique' )
With the any() function: l = input() if any([l.count(i) > 1 for i in l]): print("Deja Vu") else: print("Unique")
#it also worked text=input() n=[text.count(i) for i in text] if max(n)>=2: print ("Deja Vu") else: print ("Unique")
Also smallest: text=input() print("Deja Vu" if len(text)!=len(set(text)) else "Unique")
#Whoa. I think my code is probably the longest one here. #This code uses list, boolean and append() function. h = sorted(input()) l =  o = False for i in range(-1, len(h)-1): i+=1 i <= len(h) if h[i] == h[i-1]: l.append("Yes") else: l.append("No") if l[i] == "Yes": o = True for q in range(i+1): q+=1 if l[i] == "Yes" and l[i-q] == "No": o = True if o is True and len(h) > 1: print("Deja Vu") else: print("Unique") #If there's at least 1 string "Yes" in the list, it should print Deja Vu, otherwise it prints Unique
I have tried every way I could find but still I can't display my local images ..what am I doing wrong?
Bug: Sololearn notification is still showing number in the notification icon even i did mark as read
Izzy the iguana code coach
Finished python for beginners
Hi, hope you're doing good.Could someone please tell me why does the while loop not stop when I type in rock, paper or scissors?
C++ Question re stringstream