CS 111
Summer 1 2020

Problem Set 1 FAQ

Problem Set 1 FAQ

If you don’t see your question here, post it on Piazza or come to office hours! See the links in the navigation bar for both of those options.

General questions

  1. I get an error messageon Gradescope that reads: ‘The autograder failed to execute correctly. Please ensure that your submission is valid. Contact your course staff for help in debugging this issue. Make sure to include a link to this page so that they can help you most effectively.’

    The autograder script cannot handle print statements in the global scope, and their inclusion causes this error. The code at the bottom of the file (if __name__ == '__main__':) helps protect against this problem, which will be explained in greater detail in the next few classes.

    In the meantime, if you have any print statements that are NOT in the __main__ section, comment them out by putting a # in front of the line.

  2. I get an error message that mentions a TypeError when I add something to a list. What should I do?

    If you get something like the following error.

    TypeError: can only concatenate list (not "int") to list
    

    you are likely trying to add an integer to a list.

    Suppose you have two lists called xs and ys.

    x = [0, 1, 2]
    y = [3, 4, 5]
    

    And you would like to make a list that contains [0, 1, 2, 3]. You might try doing the following:

    x + y[0]
    

    Unfortunately, this is not allowed in Python, because addition between a list and an integer is not defined. If you think about it, this makes sense: how would you add a list to an integer? Instead, recall that the + operator can be used to concatenate two lists. Knowing this, we can put y[0] inside its own list and concatenate that with the list x.

    x + [y[0]]