break-the-ice-with-python
break-the-ice-with-python copied to clipboard
Day 2 Question 9
in this program every second string is being saved and every odd string is skipped.
Solution: change while input(): to while True: and it will be solved like below:
Why do every second line is storing in the list and all odd lines are skipped?
lst = []
while True: x = input() if len(x) != 0: lst.append(x.upper()) else: break
print(lst) for line in lst: print(line)
I had the same problem. Neither of the provided solutions is correct.
Using the not equals operator allows the user to enter blank lines as shown in the solution.
lines = []
print("Enter your text, when finished type 'end_and_print':\n")
while True:
line = input()
if line != 'end_and_print':
lines.append(line)
else:
break
print('\n'.join(lines).upper())