在完成练习3-4~练习3-7时编写的程序之一中,使用len()打印一条消息,指出你邀请了多少位嘉宾来与你共进晚餐。(练习3-6)
代码:
names=["Iron Man","Spider Man","Captain","Ant-Man"]
num=len(names)
print("I invite "+str(num)+" people for the dinne this weekend.")
运行结果:
在完成练习3-4~练习3-7时编写的程序之一中,使用len()打印一条消息,指出你邀请了多少位嘉宾来与你共进晚餐。(练习3-6)
代码:
names=["Iron Man","Spider Man","Captain","Ant-Man"]
num=len(names)
print("I invite "+str(num)+" people for the dinne this weekend.")
运行结果: