-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Open
Description
Day 13
2. Flatten the following list of lists of lists to a one dimensional list :
Wrong:
list_of_lists =[[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]]] # too many square brackets
Right:
list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Day 17
Original version:
numbers = range(2, 7) # normal call with separate arguments
print(list(numbers)) # [2, 3, 4, 5, 6]
args = [2, 7]
numbers = range(*args) # call with arguments unpacked from a list
print(numbers) # [2, 3, 4, 5,6]
we will recieve this [2, 3, 4, 5, 6]
range(2, 7)
Good version:
numbers = range(2, 7)
print(list(numbers))
args = [2, 7]
numbers = range(*args)
print(list(numbers)) # added list()
Right answers:
[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels