大家好
新手想請教一題簡單的題目
但不知為何我的答案總是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
已經試了一兩小時都還沒找到原因
所以想請大家幫忙題點我一下
感恩
感謝~