Oct-22-2021, 11:28 PM
Hello,
Does anybody know how to print the results of the code below on a single line with square brackets at the beginning and at the end and the single results separated by a comma (except after the last result)? Practically I need to get this:
[100, 400, 900, 1600]
With my coding I get this:
100 400 900 1600
Tried different ways, but I'm not getting the output in the correct format.
Does anybody know how to print the results of the code below on a single line with square brackets at the beginning and at the end and the single results separated by a comma (except after the last result)? Practically I need to get this:
[100, 400, 900, 1600]
With my coding I get this:
100 400 900 1600
Tried different ways, but I'm not getting the output in the correct format.
numbers=[10, 20, 30, 40] def square_values(numbers): return numbers**2 for current_number in numbers: current_square=square_values(current_number) print(f'{current_square} ',end='')