I have an input with newline between each string. The end will be noted by a number between 1 to 5:
Input: Ha
Ha
Hee
Hee
Ho
5
I need to accept this as list of strings in python where my list would contain: ['Ha', 'Ha', 'Hee', 'Hee', 'Ho']
After a lot of googling, I tried the following code:
lines = []
sentinel = range(6)
for i in iter(raw_input, [str(s) for s in sentinel]):
if i=='':
continue
else:
lines.append(i)
print lines
I don't know why but it goes into an infinite loop.
Please help me out!