Can please someone tell me what is wrong with my code? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
- 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!")

23rd Jul 2017, 11:00 AM
Dean Carter
Dean Carter - avatar
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')
23rd Jul 2017, 11:33 AM
Slak
Slak - avatar
+ 1
@Immortal I posted my code...? Does it restrict running the code in the question field? I never did this before...
23rd Jul 2017, 11:13 AM
Dean Carter
Dean Carter - avatar
+ 1
@Slak Thank you. You answered my question! :)
23rd Jul 2017, 11:35 AM
Dean Carter
Dean Carter - avatar
+ 1
Your welcome :)
23rd Jul 2017, 11:39 AM
Slak
Slak - avatar
+ 1
@Immortal That's all I wanted to know.
23rd Jul 2017, 11:45 AM
Dean Carter
Dean Carter - avatar
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.
23rd Jul 2017, 11:14 AM
Dean Carter
Dean Carter - avatar
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')
23rd Jul 2017, 11:22 AM
Slak
Slak - avatar
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.
23rd Jul 2017, 11:27 AM
Dean Carter
Dean Carter - avatar