1a. List and set Flashcards

1
Q

list comprehension

for i in range(9):
for j in [10,20,30,40,50]:
mylist.append(i+j)

[10, 20, 30, 40, 50, 11, 21, 31, 41, 51,

A

mylist = [i+j for i in range(9) for j in [10,20,30,40,50]]

puzzle = [[int(quiz[c+r*9]) for c in range(9)] for r in range(9)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

change a [1,2,3] into string

A

x = str(x) this won’t work as it becomes “[1,2,3]”

  1. [str(a) for a in x]
  2. map(str,x)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly