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
First, of all, I would like to thank you for creating this valuable resource and others for contributing.
Concerning Question 9, neither of the provided solutions produces the output specified in the question:
Solution 1 does not work because the program is exited before the input is appended to the list.
lst = []
while input():
x = input()
if len(x) == 0:
break
lst.append(x.upper())
for line in lst:
print(line)
Solution 2 works in part. The user can enter a single line and a capitalized line is returned. This is not the output specified in the solution. Moreover, there's no way to break from the code without initiating an EOFError using ctrl+d/z.
def user_input():
while True:
s = input()
if not s:
return
yield s
for line in map(str.upper, user_input()):
print(line)
I believe my solution gives the output specified in Question 9, with the empty line separating the two.
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())
The text was updated successfully, but these errors were encountered:
First, of all, I would like to thank you for creating this valuable resource and others for contributing.
Concerning Question 9, neither of the provided solutions produces the output specified in the question:
Solution 1 does not work because the program is exited before the input is appended to the list.
Solution 2 works in part. The user can enter a single line and a capitalized line is returned. This is not the output specified in the solution. Moreover, there's no way to break from the code without initiating an EOFError using ctrl+d/z.
I believe my solution gives the output specified in Question 9, with the empty line separating the two.
The text was updated successfully, but these errors were encountered: