Problem:
You and your friends have created a secret code!
The secret code is hidden in many lines. It's the first letter of the first line, plus the second letter of the second line, and so on, like this:
Basically it's a secret Won't they find it? Who would be looking? Nah! It's fine. B + o + o + ! spells BOO!
Your program should work like this:
Line: Basically it's a secret
Line: Won't they find it?
Line: Who would be looking?
Line: Nah! It's fine.
Line:
BOO!
到目前为止,我有这段代码,它获取输入,将每一行添加到列表中,然后当用户输入空格时停止。但我有点不确定如何获取它,因此打印第一行的第一个字母,打印第二行的第二个字母,打印第三行的第三个字母等等。Your program should read multiple lines of input, get the correct letter from each line. Then it should join each letter and print it in capitals.
listo = []
line = input("Line: ")
while line:
listo.append(line)
line = input("Line: ")
print(test)
for i in listo:
print(i[0+1])
最佳答案
这可能有效:
lines = [ '123', 'abc', 'def' ]
print ''.join( b[a] for a,b in enumerate(lines) ).upper()
打印:
1BF
关于python - 打印一行中的字母 + 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52022673/