Repository navigation
append_range.py prints instead of returning — what does the prompt's return mean here?
#28
Replies: 1 comment
|
Yes — standardize on The prompt says "returns a list", and the answer builds it correctly then throws the list away: def append_range(min_value, max_value):
empt = []
i = min_value
while i < max_value:
empt.append(i)
i += 1
print(empt) # returns NoneWhy this matters beyond style: a function that prints returns Corrected: def append_range(min_value, max_value):
result = []
i = min_value
while i < max_value:
result.append(i)
i += 1
return result
if __name__ == "__main__":
print(append_range(2, 6)) # [2, 3, 4, 5]Two smaller notes: On |
Uh oh!
There was an error while loading. Please reload this page.
python-quest/questions/append_range.mdsays the function "returns a list of integers frommin_valueup to but not includingmax_value". Butpython-quest/answers/append_range.pydoes:It prints rather than returns (a
whileloop whererange()would do, too).capitalize.pyalso prints;abort.pyreturns. Since the piscine prompts consistently say "returns", should the answers standardize onreturn?All reactions