回答編集履歴
5
追記
answer
CHANGED
@@ -29,6 +29,7 @@
|
|
29
29
|
67
|
30
30
|
>>> print(l[0],l[1],l[2])
|
31
31
|
A B C
|
32
|
+
>>> print(shift(l,2)[0])
|
33
|
+
C
|
32
34
|
>>>
|
33
|
-
|
34
35
|
```
|
4
追記
answer
CHANGED
@@ -23,6 +23,12 @@
|
|
23
23
|
['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B']
|
24
24
|
>>> shift(l,-2)
|
25
25
|
['Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X']
|
26
|
+
>>> print(l[2])
|
27
|
+
C
|
28
|
+
>>> ord(l[2])
|
29
|
+
67
|
30
|
+
>>> print(l[0],l[1],l[2])
|
31
|
+
A B C
|
26
32
|
>>>
|
27
33
|
|
28
34
|
```
|
3
追記
answer
CHANGED
@@ -9,4 +9,20 @@
|
|
9
9
|
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
10
10
|
|
11
11
|
```
|
12
|
-
つ[Pythonでリストをシフトする効率的な方法](https://codeday.me/jp/qa/20181127/23062.html)
|
12
|
+
つ[Pythonでリストをシフトする効率的な方法](https://codeday.me/jp/qa/20181127/23062.html)
|
13
|
+
|
14
|
+
```python
|
15
|
+
>>> l=[chr(i) for i in range(65,65+26)]
|
16
|
+
|
17
|
+
>>> def shift(l, n):
|
18
|
+
... return l[n:] + l[:n]
|
19
|
+
...
|
20
|
+
>>> shift(l,1)
|
21
|
+
['B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A']
|
22
|
+
>>> shift(l,2)
|
23
|
+
['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B']
|
24
|
+
>>> shift(l,-2)
|
25
|
+
['Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X']
|
26
|
+
>>>
|
27
|
+
|
28
|
+
```
|
2
追記
answer
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
Type "help", "copyright", "credits" or "license" for more information.
|
6
6
|
>>> print([chr(i) for i in range(97,97+26)])
|
7
7
|
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
|
8
|
+
>>> print([chr(i) for i in range(65,65+26)])
|
9
|
+
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
8
10
|
|
9
11
|
```
|
10
12
|
つ[Pythonでリストをシフトする効率的な方法](https://codeday.me/jp/qa/20181127/23062.html)
|
1
追記
answer
CHANGED
@@ -1,1 +1,10 @@
|
|
1
|
+
```python
|
2
|
+
usr ~ % py
|
3
|
+
Python 3.7.2 (default, Dec 29 2018, 06:19:36)
|
4
|
+
[GCC 7.3.0] :: Anaconda custom (64-bit) on linux
|
5
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
6
|
+
>>> print([chr(i) for i in range(97,97+26)])
|
7
|
+
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
|
8
|
+
|
9
|
+
```
|
1
10
|
つ[Pythonでリストをシフトする効率的な方法](https://codeday.me/jp/qa/20181127/23062.html)
|