15. Use a list comprehension to create the list below, which consists of ones separated by increasingly many zeroes.
The last two ones in the list should be separated by ten zeroes.
[1,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,....]
15. Use a list comprehension to create the list below, which consists of ones separated by increasingly many zeroes.
The last two ones in the list should be separated by ten zeroes.
[1,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,....]
[1,1]+sum([[0]*i+[1]for i in range(11)],[]); 해결 - dc App
[1]+sum([[0]*i+[1]for i in range(11)],[]); 이게맞다 - dc App
와 이건 어렵다
넹 아직 푸는 중이에요. 컴프리헨션안쓰고 만들었는데..
풀긴 했는데 답은 너 풀고 나면 올림
저 포기 했어요
포기 왤케 빠름;
이떄까지 풀고 있었는데 용
그럼 힌트로?
아 머임 포기했다고 해서 올렷는데
list3 = [1 if m == 0 else 0 for n in range(1, 11) for m in range(n)] + [1] print(list3)
근데 이렇게 for 두 번 들어가는거는 쓰지 마셈 가독성 나쁨
와 대박...
아 이렇게 하면 0이 9개까지 밖에 안 찍히네 range(1,12)로 하면 댐
님 제 스승님이 되어 주세요
L=[[1]+[0]*i for i in range(11)] L=[j for M in L for j in M]+[1] print(L) 저도 풀었어요 방금 후이이이유ㅠ 저도 나중엔 스승님처럼 빨리 풀수 있겠죠?