Python Taskbook Level 10.1
Ask the user for two numbers. Check whether these numbers are friendly or not.
Here is a list:
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
Given a variable:
n = 3;
Turn this list into a two-dimensional list, with n
elements per sublist.
Given a list:
[
[1, 2, 3, 4, 5],
[1, 2, 3],
[1, 2],
]
Add enough empty lines to each sublist so that the number of elements in each sublist is equal to the number of elements in the longest sublist.
Given a list of some data for certain dates, stored in the following structure:
data = [
{
'year': 2019,
'month': 11,
'day': 20,
'data': ['list with data']
},
{
'year': 2019,
'month': 11,
'day': 21,
'data': ['list with data']
},
{
'year': 2019,
'month': 12,
'day': 25,
'data': ['list with data']
},
{
'year': 2019,
'month': 12,
'day': 26,
'data': ['list with data']
},
{
'year': 2020,
'month': 10,
'day': 29,
'data': ['list with data']
},
{
'year': 2020,
'month': 10,
'day': 30,
'data': ['list with data']
},
{
'year': 2020,
'month': 11,
'day': 19,
'data': ['list with data']
},
{
'year': 2020,
'month': 11,
'day': 20,
'data': ['list with data']
},
]
Write code that will convert the data structure into a structure like this:
{
year1: {
month1: {
Day 1: [list of data],
Day 2: [list of data],
Day 3: [list of data],
},
month2: {
Day 1: [list of data],
Day 2: [list of data],
Day 3: [list of data],
}
},
year2: {
month1: {
Day 1: [list of data],
Day 2: [list of data],
Day 3: [list of data],
},
month2: {
Day 1: [list of data],
Day 2: [list of data],
Day 3: [list of data],
}
}
}