Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
What does app_running mean in this video? Can I just name it any other name or it is a built-in function?
app_running = True #this line here while app_running: choice = menu() if choice == '1': # add book pass elif choice == '2': # view books pass elif choice == '3': # search book pass elif choice == '4': # analysis pass else: print('GOODBYE') app_running = False #also here
Luke Impson1,203 Points
app_running is a variable, not a function. It really wouldn't matter what the variable was called as long as every instance of app_running was renamed. Your code won't run properly if you don't rename every instance of it. It's because you've set app_running equal to True. app_running is used as your condition under which your while statement will run. The while statement evaluates an expression and loops as long as that expression is True. So a 'while True' loop will run infinitely because True always equals True. Thus, since app_running is True, the following code will continue to loop until app_running = False. In this case, app_running is set to False when 'choice' is set to something other than 1, 2, 3, or 4. When it does not meet any of these if or elif statements, it follows the else statement, where 'GOODBYE' is printed and app_running is set to False, and the while loop ceases because app_running no longer is True.