NP40 梦想的大学

思路:

step1:向字典里加入键值对的方式:survey_dict[name] = university

代码如下:

survey_dict = {}
while True:
    try:
        print('If you have the chance, which university do you want to go to most?')
        print('What is your name?')
        name = input()
        print('Which university do you want to go to most?')
        university = input()
        survey_dict[name] = university
        print("Is there anyone who hasn't been investigated yet?")
        m = input()
        if m == 'No':
            break
    except:
        break

for i in sorted(survey_dict.keys()):
    print("I'am {}. I'd like to go to {} if I have the chance!".format(i,survey_dict[i]))