- 3
How do i put "if letter appears two times in a list,print deja vu" in python code đ I'm a beginner
12 Respostas
+ 2
Do not write in the input function
An approach could be to create a set with the input and then compare the length of the set with the length of the original input string.
The output must be written exactly as described in the task description
+ 1
đPlease tag "Python" when you ask about Python, not "html".
đPlease elaborate what the task is (example input and output)
đShow your attempt.
+ 1
Is it a sololearn task?
It asks for input() according to the task description?
+ 1
You can use the count method of list and conditional statements.
some_list = ['a', 'b', 'c', 'd', 'e', 'a']
letter = input()
if some_list.count(letter) > 1:
print("Deja Vu")
else:
print("Unique")
0
Input Format:
A string of random letter characters (no numbers or other buttons were pressed).
Output Format:
A string that says 'Deja Vu' if any letter is repeated in the input string, or a string that says 'Unique' if there are no repeats
0
letters="aa,bb,cc,df,ee,ff,g,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz"
string="hello"
if letters in string:
print("Deja vu")
elif letters not in string:
print("Unique
Here is my attempt above
0
Yes,it does,but i did it like that to see if it will work with my input string of which it doesn't
0
letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z/n']
string=(input("string"))
pos=0
long=len(letters)
if letters[pos]in string*2:
print("deja vu")
else:
print("unique")
This here was my second attempt
0
Sandeep i tried this but,it works with some words but some,no
0
Lisa may you please elaborate more on your answer please
0
M.e.r.c.yđđ€ it should work with everything. Maybe try adding an elif condition.
-----
You can use the count method of list and conditional statements.
some_list = ['a', 'b', 'c', 'd', 'e', 'a']
letter = input()
if some_list.count(letter) > 1:
print("Deja Vu")
elif some_list.count(letter) == 1:
print("Unique")
else:
print("")
----
0
if string.count() == 2:
# code here
I dont know, this might help though.