python 3.x - Why does my script continue to 'while' loop when if statement is true? -
at line 11, user chooses cancel button on easygui enterbox, why code continue 'while' loop though user's choice returns 'nonetype? doesn't meet condition of 'if' statement? shouldn't script return 'main' function being called?
here full script.
from easygui import* def children_menu(): title2 = "children." children_menu = ["1: register child.", "2: list of registered children."] button = buttonbox("choose option", title2, choices=children_menu) if button == children_menu[0]: enter1 = enterbox(msg="enter child's first name.", title=' ', default='', strip=true, image=none, root=none) if enter1 none: main() return else: while enter1 == "" or enter1.isalpha() == false: enter1 = enterbox(msg="invalid entry. please enter child's first name using letters only.",title=' ', default='', strip=true, image=none, root=none) enter2 = enterbox(msg="enter child's last name.", title=' ', default='', strip=true, image=none, root=none) # ask user enter child's first name while enter2 == "" or enter2.isalpha() == false: if enter2 none: main() else: enter2 = enterbox(msg="invalid entry. please enter child's last name using letters only.", title=' ', default='', strip=true, image=none,root=none) child_name = (enter1 + " " + enter2).title() file = open("children.txt", 'a') file.write(child_name + "\n") file.close() if button == children_menu[1]: file = open("children.txt", 'r') linelist = file.readlines() linelist.sort() print("list of children's names in alphabetical order:") line in linelist: print(line, end="") file.close() main() def main(): title1 = "main menu." main_menu = ["1: children", "2: groups", "3: educators", "4: tags", "5: cancel"] button = buttonbox("choose option", title1, choices=main_menu) if button == main_menu[0]: children_menu() elif button == main_menu[1]: group_menu() elif button == main_menu[2]: button = "3" title4 = "educators." educator_menu = ["1: register educator.", "2: list of registered educators."] button = buttonbox("choose option", title4, choices=educator_menu) elif button == main_menu[3]: button = "4" title4 = "tags." tags_menu = ["1: create tags", "2: list of tags."] button = buttonbox("choose option", title4, choices=tags_menu) else: button = "you cancelled." main()
Comments
Post a Comment