创建一个名为survey_dict的空字典, 请编写一个死循环, 每次循环开始先使用print()语句一行输出字符串'If you have the chance, which university do you want to go to most?', 再使用print()语句一行输出字符串'What is your name?',再将读取到的字符串存储在变量name中, 再使用print()语句一行输出字符串'Which university do you want to go to most?',再将读取到的字符串存储在变量university中, 再把键-值对name: university存储在字典survey_dict中, 再使用print()语句一行输出字符串"Is there anyone who hasn't been investigated yet?", 如果输入的字符串为'No',则使用 break 语句退出循环,否则本次循环结束,再次进入 while 循环中的条件测试。 在 while 循环结束后,使用for循环遍历 已使用sorted()函数按升序进行临时排序的包含字典survey_dict的所有键的列表, 对于每一个遍历到的被调查者的名字,使用print()语句一行输出类似字符串"I'am Tom. I'd like to go to Fudan University if I have the chance!"的语句。
输入描述:
无
输出描述:
按题目描述进行输出即可。
示例1
输入
Tom
Fudan University
Yes
Ben
Peking University
Yes
Andy
Tsinghua University
No
输出
If you have the chance, which university do you want to go to most?
What is your name?
Which university do you want to go to most?
Is there anyone who hasn't been investigated yet?
If you have the chance, which university do you want to go to most?
What is your name?
Which university do you want to go to most?
Is there anyone who hasn't been investigated yet?
If you have the chance, which university do you want to go to most?
What is your name?
Which university do you want to go to most?
Is there anyone who hasn't been investigated yet?
I'am Andy. I'd like to go to Tsinghua University if I have the chance!
I'am Ben. I'd like to go to Peking University if I have the chance!
I'am Tom. I'd like to go to Fudan University if I have the chance!
加载中...