求大佬教我一下
letter = input("Enter a letter")x = ord(letter)
if 97 <= x <=122:
while 97<= x <= 122:
print(chr(x))
x +=1
elif 65 <= x <= 90:
while 65<= x <= 90:
print(chr(x))
x +=1
假设我输入a这个代码输出的结果为:
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
但是我要输出的结果为这样应该怎么办?
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 定义一个count,每次输出count个空格,然后count+1 增加点打印空格的代码就行了
letter = input("Enter a letter")
x = ord(letter)
print(x)
if 97 <= x <=122:
temp=x
while 97<= x <= 122:
print((x-temp)*' '+chr(x))
x +=1
elif 65 <= x <= 90:
temp = x
while 65<= x <= 90:
print((x-temp)*' '+chr(x))
x +=1
页:
[1]