when using raw_input
in a loop, until a certain character is typed (say 'a'
) how can I print all the inputs before that, in reverse order, without storing the inputs in a data structure?
using a string is simple:
def foo():
x = raw_input("Enter character: ")
string = ""
while not (str(x) == "a"):
string = str(x) + "\n" + string
x = raw_input("Enter character: ")
print string.strip()
but how could I without the string? any ideas?