Confirm that it is executed with the following notation.
a,*b = [1,2,3,4,5]
** ▼ Processing content ** Substitute the very first element for a. Substitute after that for b.
python
a,*b = [1,2,3,4,5]
print(a)
print(b)
#output
1
[2,3,4,5]
a,b,c=1,2,3
print(a)
print(b)
print(c)
#output
1
2
3
▼ Error if the number of elements and the number of variables do not match
a,b=1,2,3
print(a)
print(b)
#output
too many values to unpack (expected 2)
** ▼ Asterisk eliminates the need to match the number of variables and elements **
・ Can be used at the beginning or in between.
a,*b,c,d=1,2,3,4,5,6,7,8,9
print(a)
print(b)
print(c)
print(d)
#output
1
[2, 3, 4, 5, 6, 7]
8
9
*a,b,c,d=1,2,3,4,5,6,7,8,9
print(a)
print(b)
print(c)
print(d)
#output
[1, 2, 3, 4, 5, 6]
7
8
9
name, *line = input().split()
--Divided input values including spaces and TAB into a list. --Substitute the first element for name --Substitute the following elements into line
python
n = int(input())
#Define dictionary type
student_marks = {}
for _ in range(n):
#The first element is name. After that, store in line
name, *line = input().split()
#Make the number stored in line a float and make it a list type
scores = list(map(float, line))
#Name the key,Store the value as scores in a dictionary
student_marks[name] = scores
query_name = input()
#The dictionary type for statement retrieves the key.
for key in student_marks:
if key==query_name:
#Sum to find the average()/len()
ave = sum(student_marks[key])/len(student_marks[key])
#Two decimal places display. use f string
print(f'{ave:.2f}')
f'string'
f'{variable}'
Value: .nf → Display up to n decimal places