In Python 2.7, you have:
line = raw_input("Please input a new line: ")
In Python 3.5+, you have:
line = input("Please input a new line: ")
Both raw_input
and input
return a string object.
You need to parse/scan line
to retrieve your data.
MESSAGE = "Please input a new line: "
# I comprehend that `sentences` is a list of lines
sentences = []
longest = 0
line = input(MESSAGE)
while line:
# Loop continues as long as `line` is available
# Keep a track of all the lines
sentences.append(line)
# Get the length of this line
length = len(line)
if length > longest:
longest = length
for i in range(longest):
for j in range(len(sentences) - 1, -1, -1):
if len(sentences[j]) > i:
print(sentences[j][i])
line = input(MESSAGE)
2
solved Python equivalence for this c++ program [closed]