can it is possible ? help | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

can it is possible ? help

a code is asking for user input email address and if the user input his email address but forget to put @gmail.com at last so the output code should show that this email address is invalid

5th May 2018, 3:11 AM
Anmol Dhakal
8 Antworten
+ 2
Unless only Gmail addresses are valid, use a regex instead. https://code.sololearn.com/cnbUBK5uKvnG/?ref=app
5th May 2018, 7:20 AM
Johannes
Johannes - avatar
+ 3
I don't know Python but I can provide some pseudo code: if not(inString(email, "@gmail.com")): print "Invalid Email." You basically want to test if "@gmail.com" is in the string email (assuming email is the variable name) and if it's not it's not in the string throw an error.
5th May 2018, 4:11 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 2
Jan Markus I agree that regex is probably the best solution. It's very powerful and is used for this exact purpose.
5th May 2018, 4:28 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 2
Let's Lyrics If that's what you specifically want then read up on regex. It's exactly what you're looking for.
5th May 2018, 4:32 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 2
The code I provided won't work. It's pseudo code. I don't know Python, but I know how in other languages. The code I showed is how it might look.
5th May 2018, 4:44 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
hey guys did you understand what i mean to say is? i mean to say that when a user enter his email address eg. test@gmail.com the printed should be ok continuee but if the user enter his input test.com(no @gmail present) then it should show us this email is invalid
5th May 2018, 4:31 AM
Anmol Dhakal
0
it is showing me an error if not(inString(email, "@gmail.com")): print "Invalid Email."
5th May 2018, 4:38 AM
Anmol Dhakal