fb pixel

multi-line lists

List declaration can span several lines:
months = ['January', 'February',
'March', 'April', 'May',
'June', 'July', 'August',
'September', 'October', 'November',
months = [
Both of these list declarations are valid. It’s not mandatory to have all elements on the same line. As long as there is an opening and closing brackets [], everything in between separated by commas is considered part of the list. The declaration can even have some blank lines or comments in between which will be ignored.
Once again, each list element can be treated as an ordinary variable like presented on the right. This creates a list with 2 elements which are read from the input.
l = [


Create a list of 8 numbers that are read from the user input. Multiply those values by 2 and print the list in the output.
0 4 1 3 9 -2 4 -5
[0, 8, 2, 6, 18, -4, 8, -10]
To check your solution you need to sign in
Sign in to continue