1
0
Files
pythonCrashCourse/chap3/guest_list.py
2025-05-09 10:12:44 -04:00

40 lines
2.2 KiB
Python

guest_list = ['Sir Paul McCartney', 'Kurt Harland', 'Gene Ween', 'Dean Ween']
print(f"I cordially invite {guest_list[0]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[1]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[2]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[3]} to join me for dinner this evening.")
cannot_attend = guest_list.pop(3)
print(f"\nSadly, {cannot_attend} is unable to accept the dinner invite.")
guest_list.append('Stu Mackenzie')
print(f"I cordially invite {guest_list[0]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[1]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[2]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[3]} to join me for dinner this evening.")
print("\nA bigger table was found. Inviting more guests.")
guest_list.insert(0, 'Sir Ringo Starr')
guest_list.insert(2, 'John Paul Densmore')
print(f"I cordially invite {guest_list[0]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[1]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[2]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[3]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[4]} to join me for dinner this evening.")
print(f"I cordially invite {guest_list[5]} to join me for dinner this evening.")
print("\nThe table will not arrive in time, so guest list will be cut down to two.")
remove_guest1 = guest_list.pop(2)
remove_guest2 = guest_list.pop(2)
remove_guest3 = guest_list.pop(2)
remove_guest4 = guest_list.pop(2)
print(f"Sorry, {remove_guest1}, but I cannot invite you to dinner.")
print(f"Sorry, {remove_guest2}, but I cannot invite you to dinner.")
print(f"Sorry, {remove_guest3}, but I cannot invite you to dinner.")
print(f"Sorry, {remove_guest4}, but I cannot invite you to dinner.")
print(f"\nI still cordially invite {guest_list[0]} to join me for dinner this evening.")
print(f"I still cordially invite {guest_list[1]} to join me for dinner this evening.")
print("\nDeleting the guest list...")
del guest_list[0]
del guest_list[0]
print(guest_list)