我是一个编程新手,我必须做一个挑战,让列表中的每个人都得到一个邀请,但不是把数字改7次,我相信一定有更简单的方法。这是我设法做到的。请随意批评我。你知道吗
plus_one= 'hitler'
guest_list = ['john carter', 'emilia airheart', 'god']
print ("Dear, \n" + guest_list[1].title() + ", you are invited to a warm get together. unfortunately " + busy.title(),"couldn't make it "
+ "but luckily " + plus_one.title() + " managed to appear" )
guest_list.append('hitler')
guest_list.insert(-3, "bob ross")
guest_list.insert(0, 'jerry seinfeld')
guest_list.append('micheal')
print(guest_list)
这就是你要找的吗?你知道吗
为了对来宾列表中的每个条目执行操作,您可以运行一个循环:
简单示例:
现在可以定义一个函数,将来宾的名字插入到字符串中并打印出来。然后在循环中调用该函数。你知道吗
这是非常基本的Python。在你进一步提问之前,你应该先做一个初学者教程。你知道吗
这就是你要找的吗?你知道吗
相关问题 更多 >
编程相关推荐