Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append function doesn't work / list returns empty #1

Open
KIBautista opened this issue May 20, 2019 · 1 comment
Open

Append function doesn't work / list returns empty #1

KIBautista opened this issue May 20, 2019 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@KIBautista
Copy link
Owner

When I run through the program and enter items, they do not show up in the end when you enter "show" to return the list. Could anyone help with how to fix that issue?

@KIBautista KIBautista added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels May 20, 2019
@Sparrow1029
Copy link

Hello! I believe it's an indentation error. Python uses indentation to delineate blocks of code, so your main loop should look like this to get the desired functionality (I added | pipe characters to illustrate the indentation):

while True:
    new_item = input("> ")
    |
    if new_item == 'DONE':
    |   break
    elif new_item == 'HELP':
    |   show_help()
    |   continue
    elif new_item == 'SHOW':
    |   show_list()  # <-- These two lines are under-indented
    |   continue     # <-- Should be 4 spaces
    |
    add_to_list(new_item)  # <- needs to be in-line with rest of 'while' block

It might also be better to add an explicit else statement like

    else:
        add_to_list(new_item)

to be clearer about the control flow. I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants