cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
aj-v
Community Member

Need help with fill-in-the-blanks on quizzes - my answers need square brackets

Hello everyone,

I'm teaching a Python programming class and we're doing a unit on lists, which in Python use the square brackets.  Certain operations change the contents of the list, and I'd like to quiz students on this by having a small program that does several list manipulations and prints the list after each change. 

The question would look like this:

-----------------------------------------

Write what will be printed by each of the print statements in the following code.

ex = [5, 3, 0, 1, 2] 
print(ex) # Answer A
print(ex[0:2]) # Answer B
print(ex[-1]) # Answer C
ex.append(8) 
print(ex) # Answer D
ex.remove(0) 
print(ex) # Answer E
ex.pop() 
print(ex) # Answer F

Enter your answers here:

  • Answer A [A]
  • Answer B [B]
  • Answer C [C]
  • Answer D [D]
  • Answer E [E]
  • Answer F [F]

--------------------------------------------

The trouble is, the answer for A is [5, 3, 0, 1, 2] (the list before anything is done) and most of the other answers are also lists. I can't seem to get Canvas to accept answers in square brackets as non-empty, so I cannot save this question to the quiz.    

Labels (1)
0 Kudos
1 Reply
gpillsbury
Community Participant

Hmm.  I was able to create an answer that used [ ] brackets as part of it.  You can see that in the screenshot below, as part of "Answer 2":

Screen Shot 2021-10-25 at 1.14.30 PM.png

Is that what you're trying to do?

-Glenn