Skip to content

Instantly share code, notes, and snippets.

@jmangrad
Last active October 28, 2023 20:23
Show Gist options
  • Save jmangrad/1714b697e43f519b7961d39557c6cb35 to your computer and use it in GitHub Desktop.
Save jmangrad/1714b697e43f519b7961d39557c6cb35 to your computer and use it in GitHub Desktop.
Python Crash Course
8-9. Messages: Make a list containing a series of short text messages. Pass the
list to a function called show_messages(), which prints each text message.
8-10. Sending Messages: Start with a copy of your program from Exercise 8-9.
Write a function called send_messages() that prints each text message and
moves each message to a new list called sent_messages as it’s printed. After
calling the function, print both of your lists to make sure the messages were
moved correctly.
8.9 Answer
def show_messages(messages):
for message in messages:
print("You have {}".format(message))
my_list = ['one unread email', 'one voice mail', 'to go to the dentist today']
show_messages(my_list)
8.10 Answer
def show_messages(messages, sent_messages):
while messages:
current_message = messages.pop()
print("current message: {}".format(current_message))
sent_messages.append(current_message)
def send_messages(sent_messages):
print("\nThe following messages have been sent:")
for sent_message in sent_messages:
print("You have {}".format(sent_message))
messages = ['one unread email', 'one voice mail', 'to go to the dentist today']
sent_messages = []
show_messages(messages, sent_messages)
send_messages(sent_messages)
@Shoveroacto
Copy link

I am currently faced with one of the most difficult tasks I have encountered so far. Understanding the subtleties and consistency of the processes involved has been quite a challenge for me. Surprisingly, I had no such difficulties when writing an essay on underserved populations. In that case, I simply referred to a few examples from https://eduzaurus.com/free-essay-samples/underserved-populations/ to create my own version. However, in my current work, even though the answers are available, I still find it difficult to fully grasp the concepts. Nevertheless, participating in this course in my spare time has its benefits, contributing to my intellectual growth. I believe that with persistence, everything will fall into place as it should.

@Leonardbrit
Copy link

So far, this is probably the most difficult task for me at the moment for understanding all the processes and sequence. I didn't have such a hard time even when I was writing an essay about personal identity, there I just looked at a couple of examples from do my assignment and used them to make my own version. And here even having an answer it is still hard for me to understand what is what. But as a course that I take in my spare time it also helps me to be smart, so everything goes as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment