发布网友 发布时间:2022-04-26 17:35
共2个回答
热心网友 时间:2023-10-17 21:13
def display_rotated(character, n):
alph = ['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 index in range(27):
if alph[index] == character:
return alph[(index + n)%26]
else:
pass
def upper_every_nth(string, n):
l1 = [i for i in string]
l2 = [i for i in range(len(string)) if i%n == 0]
s = ''
index = 0
while index <= len(string):
if index in l2:
l1[index] = l1[index].upper()
index += 1
for i in l1:
s += i
return s
追问
这两题我试了一下还是错误
热心网友 时间:2023-10-17 21:13
第一题:
def display_rotated(character, n):至于第二题:
ord('a') == 97
ord('A') == 65
这样就很简单了吧
chr(ord(character)-32)
第一题用了这方法还是错
我真是服你的智商了,看不懂错误提示吗?
明显的缩进错误。
你学python,难道不知道缩进?