You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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())
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)
The text was updated successfully, but these errors were encountered: