列表

详情


NP16. 发送offer

描述

某公司在面试结束后,创建了一个依次包含字符串 'Allen' 和 'Tom' 的列表offer_list,作为通过面试的名单。
请你依次对列表中的名字发送类似 'Allen, you have passed our interview and will soon become a member of our company.' 的句子。
但由于Tom有了其他的选择,没有确认这个offer,HR选择了正好能够确认这个offer的Andy,所以请把列表offer_list中 'Tom' 的名字换成 'Andy' ,
再依次发送类似 'Andy, welcome to join us!' 的句子。

输入描述

输出描述

按题目描述进行输出即可。
Allen, you have passed our interview and will soon become a member of our company.
Tom, you have passed our interview and will soon become a member of our company.
Allen, welcome to join us!
Andy, welcome to join us!

原站题解

Python 解法, 执行用时: 10ms, 内存消耗: 2824KB, 提交时间: 2022-08-05

offer_list = ['Allen','Tom']
 
# out
for i in range(len(offer_list)):
    print('{}, you have passed our interview and will soon become a member of our company.'.format(offer_list[i]))
     
     
for str_i in offer_list:
    if str_i == 'Tom':
        print('Andy, welcome to join us!' )
    else:
        print('{}, welcome to join us!'.format(str_i) )

Python 解法, 执行用时: 10ms, 内存消耗: 2828KB, 提交时间: 2022-07-09

offer_list = ['Allen','Tom']
for i in offer_list:
    print(i + ', you have passed our interview and will soon become a member of our company.')
offer_list.remove('Tom')
offer_list.append('Andy')
for j in offer_list:
    print(j + ', welcome to join us!')

Python 解法, 执行用时: 10ms, 内存消耗: 2832KB, 提交时间: 2022-07-03

offer_list = ['Allen','Tom'] 
for i in offer_list: 
    print(i + ", you have passed our interview and will soon become a member of our company.") 
offer_list.remove('Tom') 
offer_list.append('Andy')
for j in offer_list: 
    print(j + ", welcome to join us!")

Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-07-29

offer_list = ['Allen','Tom']
for i in offer_list:
    print('%s, you have passed our interview and will soon become a member of our company.' %i)
offer_list[1] = 'Andy'
for n in offer_list:
    print('%s, welcome to join us!' %n)

Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-06-29

list=['Allen','Tom']
for str in list:
    print("{}, you have passed our interview and will soon become a member of our company.".format(str))
    
list.remove("Tom")
list.append("Andy")

for str in list:
    print("{}, welcome to join us!".format(str))
   

上一题