Now there is a group of students named Qimeng , Lengyiyi , Xiangning , Zixuan , Zero language , San Bo ; Their birthplace
Shandong 、 shanxi 、 hunan 、 Inner Mongolia , Shandong , shanxi .
(1) Use the collection to record the list of students and the place of origin ;
(2) Use the set to construct the student list of the same province .
The code I wrote :
student_name = [' Dream ',' Lengyiyi ',' Xiangning ',' Zixuan ',' Zero language ',' San Bo ']
student_name1 = set (student_name)
print (student_name1)
birthplace = [' Shandong ',' shanxi ',' hunan ',' Inner Mongolia ',' Shandong ',' shanxi ']
birthplace1 = set (birthplace)
print (birthplace1)
dictionary = dict(zip(student_name,birthplace))
print (dictionary)
for student_name,birthplace in dictionary.items():
dict.setdefault(birthplace,set()).add(student_name)
student = [ len(values) > 1]
printf(student)
Operational results to be achieved :
img
Results of my current run :
img