- 1
Can please someone tell me what is wrong with my code?
I am trying to write a code to display the message "Well done" after user input is recognized. This is still a work in progress. Here is the code: user_input=input("Enter your name") def lc_alphabet: lc={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} def uc_alphabet: uc={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} #Assigning each case of alphabet to be valid as an input. lc_alphabet=uc_alphabet if lc_alphabet=uc_alphabet: print("Well done!")
8 Respuestas
0
ooo ok
first is you define a function you need to add ()
second you need code for a function, you can't leave it empty
def lc_alphabet():
print('place holder')
also to check if stuf is equal to one another use ==
if 1==1:
print('one is equal to one')
+ 1
@Immortal I posted my code...? Does it restrict running the code in the question field? I never did this before...
+ 1
@Slak Thank you. You answered my question! :)
+ 1
Your welcome :)
+ 1
@Immortal That's all I wanted to know.
0
user_input=input("Enter your name")
#Defining the lower-case alphabet to be used in the code.
def lc_alphabet:
lc={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}
#Defining the upper-case alphabet to be used in the code.
def uc_alphabet:
uc={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}
#Assigning each case of alphabet to be valid as an input.
lc_alphabet=uc_alphabet
if lc_alphabet=uc_alphabet:
print("Well done!")
Here is my code.
0
I don't think I understand fully what you want to do but this code check if caracters user input is contained in lc or uc:
user_input = input('enter text: ')
lc = {'a','b','c','d'}
uc = {'A','B','C','D'}
#for every character
for i in user_input:
if i in lc:
continue
elif i in uc:
continue
else:
#handel the wrong input here
print(i + ' is not a valid caracter')
0
I don't think I was clear enough. I am getting a syntax error right after
def lc_alphabet:
and i don't know why. Also, I'm writing an entirely different code. This code is purely to test my syntax validity. Those assignments for upper and lowercase have their use later in my code. All I need help with is my syntax error.