[Tutor] email validation
Alan Gauld
alan.gauld at btinternet.com
Mon Aug 3 09:19:01 CEST 2015
On 03/08/15 04:02, Quiles, Stephanie wrote:
> ok so i made a few corrections based on what you stated and moved the name variable out of the loop. however, now its doing the same thing with alternate email.
So you need a while loop for every element you want to validate.
while True: # overall loop per user
while True: # get user details
get and check name
while True: # email 1
get and check email1
while True: # email2
get and check email2
This is obviously repetitive so you could write a function:
get_and_check(prompt,check):
while True:
val = input(prompt)
if check(val) : return val
but since it relies on you passing in a function object (check)
that may be too advanced for you at this stage.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list