Changeset 11548


Ignore:
Timestamp:
27 Mar 2014, 13:56:28 (10 years ago)
Author:
Henrik Bettermann
Message:

Check length of student id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/pyfprint/trunk/enroll-script.py

    r11547 r11548  
    3232    """Get a student id via input from keyboard.
    3333
    34     We require the id two times (for safety). The id must not be
    35     empty.
     34    We require the id two times (for safety). The id must have length 8.
    3635    """
    3736    while True:
    3837        stud_id = raw_input("Please ENTER the STUDENT ID: ")
    39         ctrl_id = raw_input("Please repeat              : ")
    40         if not stud_id:
     38        if len(stud_id) != 8:
    4139            print "Please enter a valid student ID!"
    42             stud_id = None
    43         if stud_id != ctrl_id:
    44             print "IDs do not match. We restart."
    45         if stud_id and stud_id == ctrl_id:
    46             return stud_id
     40        else:
     41            ctrl_id = raw_input("Please repeat              : ")
     42            if stud_id != ctrl_id:
     43                print "IDs do not match. We restart."
     44            else:
     45                return stud_id
    4746
    4847
Note: See TracChangeset for help on using the changeset viewer.