我寫一個應該打印的程序:如何在python中打印字母表?
A abcdefghijklmnopqrstuvwxyz
B bcdefghijklmnopqrstuvwxyz
C cdefghijklmnopqrstuvwxyz
D defghijklmnopqrstuvwxyz
E efghijklmnopqrstuvwxyz
F fghijklmnopqrstuvwxyz
G ghijklmnopqrstuvwxyz
H hijklmnopqrstuvwxyz
I ijklmnopqrstuvwxyz
J jklmnopqrstuvwxyz
K klmnopqrstuvwxyz
L lmnopqrstuvwxyz
M mnopqrstuvwxyz
N nopqrstuvwxyz
O opqrstuvwxyz
P pqrstuvwxyz
Q qrstuvwxyz
R rstuvwxyz
S stuvwxyz
T tuvwxyz
U uvwxyz
V wxyz
X xyz
Y yz
Z z
我寫了下面的代碼的程序,但它不會打印出我想要它。這就是我對編寫的程序:
alphabet = ['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']
for k in range(len(alphabet)):
for j in range(len(alphabet)):
print(alphabet[j-k],end='')
print('\n')`
,並打印出:
abcdefghijklmnopqrstuvwxyz
zabcdefghijklmnopqrstuvwxy
yzabcdefghijklmnopqrstuvwx
xyzabcdefghijklmnopqrstuvw
wxyzabcdefghijklmnopqrstuv
vwxyzabcdefghijklmnopqrstu
uvwxyzabcdefghijklmnopqrst
tuvwxyzabcdefghijklmnopqrs
stuvwxyzabcdefghijklmnopqr
rstuvwxyzabcdefghijklmnopq
qrstuvwxyzabcdefghijklmnop
pqrstuvwxyzabcdefghijklmno
opqrstuvwxyzabcdefghijklmn
nopqrstuvwxyzabcdefghijklm
mnopqrstuvwxyzabcdefghijkl
lmnopqrstuvwxyzabcdefghijk
klmnopqrstuvwxyzabcdefghij
jklmnopqrstuvwxyzabcdefghi
ijklmnopqrstuvwxyzabcdefgh
hijklmnopqrstuvwxyzabcdefg
ghijklmnopqrstuvwxyzabcdef
fghijklmnopqrstuvwxyzabcde
efghijklmnopqrstuvwxyzabcd
defghijklmnopqrstuvwxyzabc
cdefghijklmnopqrstuvwxyzab
bcdefghijklmnopqrstuvwxyza
abcdefghijklmnopqrstuvwxyz
我需要幫助找出我做錯了什麼,我需要的代碼打印做我想要它打印什麼。
請注意,與示例不同,每個打印行的長度均爲26.您爲什麼認爲這是?另外,你認爲,例如,字母[-5]是什麼? –