O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

3-5. Changing Guest List:

From

Cover of Python Crash Course

Note

message1 = 'Hi, '
message2 = 'would you like to join me for dinner tonight?'
names = ['Ruby', 'Java', 'Jay', 'Alicia']
loop = 0
for name in names:
print(message1 + name + message2)
absentee = 'Java'
newguest = 'Linux'
print("Oops, it looks like " + absentee + "could not make it!")
print("Invite " + newguest + " then!")
print("The revised invitation list: ")
names.remove(absentee)
names.append(newguest)
print(names)