[Tutor] email validation
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:
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.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor