大家好
新手想请教一题简单的题目
但不知为何我的答案总是Z
似乎没有成功loop
还请大家赐教 感谢!
题目:
Write a program that takes a character as input (a string of length 1), which
you should assume is an upper-case character; the output should be the next
character in the alphabet. If the input is 'Z', your output should be 'A'.
(You will need to use an if statement. )
我的code:
for i in range(65,90):
input=chr(i)
if input!="Z":
output=chr(ord(input)+1)
else:
output=="A"
print (output)
注:因为65-90就是A到Z的index
但我的code是不论他给我input为多少
我的program output都是Z
已经试了一两小时都还没找到原因
所以想请大家帮忙题点我一下
感恩
感谢~